Skip to content

Commit

Permalink
test(integration): Improve integration test stability (#389)
Browse files Browse the repository at this point in the history
* Remove legacy `Executor` class.
* Add dev dependency on [execa](https://github.com/sindresorhus/execa) to spawn child processes during integration testing
* Pipe output to host process as that seems to be the most stable for travis builds (don't now why)
* Configure all integration tests as "info" to reduce integration test output.
  • Loading branch information
nicojs authored and simondel committed Oct 1, 2017
1 parent 3445cbf commit 66f61fb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 72 deletions.
56 changes: 0 additions & 56 deletions integrationTest/Executor.ts

This file was deleted.

5 changes: 4 additions & 1 deletion integrationTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
"typescript": "^2.4.2"
},
"scripts": {
"postinstall": "install-local && link-parent-bin -c test --link-local-dependencies true"
"postinstall": "install-local && link-parent-bin -c test --link-local-dependencies true",
"build": "tsc",
"pretest": "npm run build",
"test": "mocha run-integration-test.js"
},
"localDependencies": {
"grunt-stryker": "../packages/grunt-stryker",
Expand Down
25 changes: 11 additions & 14 deletions integrationTest/run-integration-test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
import * as fs from 'fs';
import * as path from 'path';
import Executor from './Executor';
import execa = require('execa');

describe('integration-tests', function () {

this.timeout(500000);

before(done => {
new Executor('.').exec('npm install', {}, done);
before(() => {
console.log(' Exec npm install...');
return execa('npm', ['install'], { cwd: __dirname });
});

const root = path.join('integrationTest', 'test');
const dirs = fs.readdirSync(root)
.filter(f => fs.statSync(path.join(root, f)).isDirectory());
const testRootDir = path.resolve(__dirname, 'test');
const dirs = fs.readdirSync(testRootDir)
.filter(file => fs.statSync(path.join(testRootDir, file)).isDirectory());
dirs.forEach(testDir => {
describe(testDir, () => {
it('should run test', (done) => {
new Executor(path.join('test', testDir)).exec('npm test', {}, error => {
if (error) {
done(new Error(error));
} else {
done();
}
});
it('should run test', () => {
const currentTestDir = path.resolve(testRootDir, testDir);
console.log(` Exec ${testDir} npm test`);
execa.sync('npm', ['test'], { cwd: currentTestDir });
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion integrationTest/test/grunt-stryker-test/stryker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function (config) {
],
testFramework: 'jasmine',
testRunner: 'karma',
logLevel: 'debug',
logLevel: 'info',
maxConcurrentTestRunners: 2,
port: 9234
});
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@types/escodegen": "0.0.6",
"@types/esprima": "^2.1.31",
"@types/estree": "0.0.32",
"@types/execa": "^0.7.0",
"@types/express-serve-static-core": "4.0.46",
"@types/glob": "^5.0.29",
"@types/istanbul": "^0.4.29",
Expand All @@ -24,6 +25,7 @@
"chai": "^4.1.1",
"chai-as-promised": "^7.1.1",
"concurrently": "^3.4.0",
"execa": "^0.8.0",
"glob": "^7.1.1",
"lerna": "^2.0.0",
"link-parent-bin": "^0.1.1",
Expand Down

0 comments on commit 66f61fb

Please sign in to comment.