Skip to content

Commit

Permalink
Merge pull request #344 from halfzebra/fix-test-runner
Browse files Browse the repository at this point in the history
fix: test script by changing the way it resolves the path to elm binary
  • Loading branch information
halfzebra authored Feb 26, 2019
2 parents 7b29611 + a5a062d commit c743ad1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 4 additions & 2 deletions bin/elm-app-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ switch (script) {
}
});

args = args.concat(['--compiler', elmExecutable]);

args = args.concat([
'--compiler',
path.join(path.dirname(require.resolve('elm')), '/unpacked_bin/elm')
]);
const cp = spawn.sync(require.resolve('elm-test/bin/elm-test'), args, {
stdio: 'inherit'
});
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"dotenv": "^5.0.0",
"elm": "0.19.0-bugfix6",
"elm-hot-webpack-loader": "^1.0.2",
"elm-test": "^0.19.0-rev3",
"elm-test": "^0.19.0-rev5",
"elm-webpack-loader": "^5.0.0",
"file-loader": "^1.1.6",
"fs-extra": "^6.0.1",
Expand Down Expand Up @@ -65,6 +65,7 @@
"@commitlint/config-conventional": "^7.5.0",
"babel-eslint": "^8.2.1",
"commitizen": "^3.0.5",
"cross-env": "^5.2.0",
"cz-conventional-changelog": "^2.1.0",
"dir-compare": "^1.4.0",
"eslint": "^4.18.0",
Expand All @@ -76,6 +77,7 @@
"prettier": "^1.10.2",
"rimraf": "^2.6.2",
"semantic-release": "15.12.4",
"shelljs": "^0.8.3",
"unexpected": "^10.37.2"
},
"engines": {
Expand Down Expand Up @@ -111,7 +113,7 @@
"semantic-release": "semantic-release",
"test": "npm run test:cli && npm run test:functional",
"test:cli": "mocha tests/cliAccessibility.js --reporter spec --timeout 15000",
"test:functional": "UNEXPECTED_FULL_TRACE=true mocha tests/*.spec.js --reporter spec --timeout 15000",
"test:functional": "cross-env UNEXPECTED_FULL_TRACE=true mocha tests/*.spec.js --reporter spec --timeout 15000",
"app:build": "cd template && node ../bin/elm-app-cli.js build",
"app:start": "cd template && node ../bin/elm-app-cli.js start",
"app:test": "cd template && node ../bin/elm-app-cli.js test"
Expand Down
10 changes: 7 additions & 3 deletions tests/elm-app.test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ const spawn = require('cross-spawn');
const rimraf = require('rimraf');
const expect = require('unexpected');

const testAppName = 'test-app';
const testAppName = 'test-app-eject';
const rootDir = path.resolve(__dirname, '..');
const testAppDir = path.join(rootDir, testAppName);
const createElmAppCmd = path.join(rootDir, 'bin/create-elm-app-cli.js');
const elmAppCmd = path.join(rootDir, 'bin/elm-app-cli.js');

describe('Testing Elm application with `elm-app test` (Please wait...)', () => {
before(done => {
const { status } = spawn.sync('node', [createElmAppCmd, testAppName]);
const { status, stderr } = spawn.sync('node', [
createElmAppCmd,
testAppName
]);
if (status === 0) {
done();
} else {
console.log(stderr.toString());
done(false);
}
});
Expand All @@ -31,8 +35,8 @@ describe('Testing Elm application with `elm-app test` (Please wait...)', () => {
.map(out => (out !== null ? out.toString() : ''))
.join('');

expect(status, 'to be', 2);
expect(outputString, 'to contain', 'This test should fail');
expect(outputString, 'to contain', 'failed as expected!');
expect(status, 'to be', 2);
}).timeout(2 * 60 * 1000);
});

0 comments on commit c743ad1

Please sign in to comment.