Skip to content

Commit

Permalink
feat(test-frameworks): Remove side effects from all test-framework pl…
Browse files Browse the repository at this point in the history
…ugins (#1319)

Remove side effects from all test framework plugins.

* stryker-jasmine
* stryker-mocha-framework
  • Loading branch information
nicojs authored Feb 5, 2019
1 parent 1f61bed commit a7160f4
Show file tree
Hide file tree
Showing 13 changed files with 2,251 additions and 7,230 deletions.
9,029 changes: 2,035 additions & 6,994 deletions e2e/package-lock.json

Large diffs are not rendered by default.

80 changes: 37 additions & 43 deletions packages/stryker-api/package.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,39 @@
{
"name": "stryker-api",
"version": "0.23.0",
"description": "The api for the extendable JavaScript mutation testing framework Stryker",
"scripts": {
"start": "tsc -w",
"clean": "rimraf \"+(*.d.ts|*.js|*.map)\" \"src/**/+(*.d.ts|*.js|*.map)\" \"test/**/+(*.d.ts|*.js|*.map)\" \"testResources/module/+(*.d.ts|*.js|*.map)\" \"testResources/module/node_modules/stryker-api\" .nyc_output reports",
"test": "nyc --reporter=html --report-dir=reports/coverage --lines 90 --functions 68 --branches 63 npm run mocha",
"mocha": "mocha \"test/unit/**/*.js\" && mocha --timeout 100000 \"test/integration/**/*.js\""
},
"repository": {
"type": "git",
"url": "https://github.com/stryker-mutator/stryker"
},
"keywords": [
"mutation testing",
"mutation",
"testing",
"test",
"js",
"stryker"
],
"contributors": [
"nicojs <[email protected]>",
"Alex van Assem <[email protected]>",
"Jeremy Nagel <[email protected]>",
"Philipp Weissenbacher <[email protected]>",
"Simon de Lang <[email protected]>"
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/stryker-mutator/stryker/issues"
},
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/stryker-api#readme",
"engines": {
"node": ">=6"
},
"dependencies": {
"tslib": "~1.9.3"
},
"devDependencies": {
"surrial": "~0.1.1",
"typed-inject": "^0.1.1"
}
"name": "stryker-api",
"version": "0.23.0",
"description": "The api for the extendable JavaScript mutation testing framework Stryker",
"repository": {
"type": "git",
"url": "https://github.com/stryker-mutator/stryker"
},
"keywords": [
"mutation testing",
"mutation",
"testing",
"test",
"js",
"stryker"
],
"contributors": [
"nicojs <[email protected]>",
"Alex van Assem <[email protected]>",
"Jeremy Nagel <[email protected]>",
"Philipp Weissenbacher <[email protected]>",
"Simon de Lang <[email protected]>"
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/stryker-mutator/stryker/issues"
},
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/stryker-api#readme",
"engines": {
"node": ">=6"
},
"dependencies": {
"tslib": "~1.9.3"
},
"devDependencies": {
"surrial": "~0.1.1",
"typed-inject": "^0.1.1"
}
}
6 changes: 4 additions & 2 deletions packages/stryker-jasmine/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { TestFrameworkFactory } from 'stryker-api/test_framework';
import JasmineTestFramework from './JasmineTestFramework';
import { declareClassPlugin, PluginKind } from 'stryker-api/plugin';

TestFrameworkFactory.instance().register('jasmine', JasmineTestFramework);
export const strykerPlugins = [
declareClassPlugin(PluginKind.TestFramework, 'jasmine', JasmineTestFramework)
];
26 changes: 3 additions & 23 deletions packages/stryker-jasmine/test/unit/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
import * as sinon from 'sinon';
import * as path from 'path';
import { TestFrameworkFactory } from 'stryker-api/test_framework';
import { expect } from 'chai';
import { strykerPlugins } from '../..';
import JasmineTestFramework from '../../src/JasmineTestFramework';

describe('index', () => {
let sandbox: sinon.SinonSandbox;

const mockFactory = () => ({ register: sinon.stub() });
let testFrameworkFactoryMock: any;

beforeEach(() => {
sandbox = sinon.createSandbox();
testFrameworkFactoryMock = mockFactory();

sandbox.stub(TestFrameworkFactory, 'instance').returns(testFrameworkFactoryMock);

// Not import the `index` file es6 style, because we need to
// make sure it is re-imported every time.
const indexPath = path.resolve('./src/index.js');
delete require.cache[indexPath];
require('../../src/index');
it('should export strykerPlugins', () => {
expect(strykerPlugins[0].injectableClass).eq(JasmineTestFramework);
});

it('should register the JasmineTestFramework', () =>
expect(testFrameworkFactoryMock.register).to.have.been.calledWith('jasmine', JasmineTestFramework));

afterEach(() => sandbox.restore());
});
104 changes: 49 additions & 55 deletions packages/stryker-jest-runner/package.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,53 @@
{
"name": "stryker-jest-runner",
"version": "1.3.0",
"description": "A plugin to use the jest test runner and framework in Stryker, the JavaScript mutation testing framework",
"main": "src/index.js",
"scripts": {
"start": "tsc -w",
"clean": "rimraf \"+(test|src)/**/*+(.d.ts|.js|.map)\" .nyc_output reports coverage",
"test": "nyc --reporter=html --report-dir=reports/coverage --lines 80 --functions 80 --branches 75 npm run mocha",
"mocha": "mocha \"test/helpers/**/*.js\" \"test/unit/**/*.js\" && mocha --timeout 30000 \"test/helpers/**/*.js\" \"test/integration/**/*.js\" --exit"
},
"repository": {
"type": "git",
"url": "https://github.com/stryker-mutator/stryker.git"
},
"engines": {
"node": ">=6"
},
"keywords": [
"stryker",
"stryker-plugin",
"jest",
"stryker-test-runner"
],
"author": "Sander koenders <[email protected]>",
"contributors": [
"Maarten Mulders <[email protected]>",
"mshogren <[email protected]>",
"Nico Jansen <[email protected]>",
"Simon de Lang <[email protected]>",
"Philipp Weissenbacher <[email protected]>",
"Sander koenders <[email protected]>"
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/stryker-mutator/stryker/issues"
},
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/stryker-jest-runner#readme",
"devDependencies": {
"name": "stryker-jest-runner",
"version": "1.3.0",
"description": "A plugin to use the jest test runner and framework in Stryker, the JavaScript mutation testing framework",
"main": "src/index.js",
"repository": {
"type": "git",
"url": "https://github.com/stryker-mutator/stryker.git"
},
"engines": {
"node": ">=6"
},
"keywords": [
"stryker",
"stryker-plugin",
"jest",
"stryker-test-runner"
],
"author": "Sander koenders <[email protected]>",
"contributors": [
"Maarten Mulders <[email protected]>",
"mshogren <[email protected]>",
"Nico Jansen <[email protected]>",
"Simon de Lang <[email protected]>",
"Philipp Weissenbacher <[email protected]>",
"Sander koenders <[email protected]>"
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/stryker-mutator/stryker/issues"
},
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/stryker-jest-runner#readme",
"devDependencies": {
"@stryker-mutator/test-helpers": "0.0.0",
"@types/semver": "~5.5.0",
"jest": "~23.6.0",
"react": "~16.7.0",
"react-dom": "~16.7.0",
"react-scripts": "~2.1.0",
"react-scripts-ts": "~3.1.0",
"@types/semver": "~5.5.0",
"jest": "~23.6.0",
"react": "~16.7.0",
"react-dom": "~16.7.0",
"react-scripts": "~2.1.0",
"react-scripts-ts": "~3.1.0",
"stryker-api": "^0.23.0"
},
"peerDependencies": {
"jest": ">= 22.0.0",
"stryker-api": ">=0.18.0 <0.24.0"
},
"dependencies": {
"semver": "~5.6.0"
},
"initStrykerConfig": {
"coverageAnalysis": "off"
}
},
"peerDependencies": {
"jest": ">= 22.0.0",
"stryker-api": ">=0.18.0 <0.24.0"
},
"dependencies": {
"semver": "~5.6.0"
},
"initStrykerConfig": {
"coverageAnalysis": "off"
}
}
6 changes: 4 additions & 2 deletions packages/stryker-mocha-framework/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { TestFrameworkFactory } from 'stryker-api/test_framework';

import MochaTestFramework from './MochaTestFramework';
import { PluginKind, declareClassPlugin } from 'stryker-api/plugin';

TestFrameworkFactory.instance().register('mocha', MochaTestFramework);
export const strykerPlugins = [
declareClassPlugin(PluginKind.TestFramework, 'mocha', MochaTestFramework)
];
82 changes: 38 additions & 44 deletions packages/stryker-mocha-runner/package.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,43 @@
{
"name": "stryker-mocha-runner",
"version": "0.16.0",
"description": "A plugin to use the mocha test runner in Stryker, the JavaScript mutation testing framework",
"main": "src/index.js",
"scripts": {
"start": "tsc -w",
"clean": "rimraf \"+(test|src)/**/*+(.d.ts|.js|.map)\" .nyc_output reports coverage",
"test": "nyc --reporter=html --report-dir=reports/coverage --lines 80 --functions 80 --branches 75 npm run mocha",
"mocha": "mocha \"test/helpers/**/*.js\" \"test/unit/**/*.js\" && mocha --timeout 10000 \"test/helpers/**/*.js\" \"test/integration/**/*.js\""
},
"repository": {
"type": "git",
"url": "https://github.com/stryker-mutator/stryker"
},
"engines": {
"node": ">=6"
},
"keywords": [
"stryker",
"stryker-plugin",
"mocha",
"stryker-test-runner"
],
"author": "Simon de Lang <[email protected]>",
"contributors": [
"Nico Jansen <[email protected]>",
"Simon de Lang <[email protected]>"
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/stryker-mutator/stryker/issues"
},
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/stryker-mocha-runner#readme",
"dependencies": {
"multimatch": "~3.0.0",
"tslib": "~1.9.3"
},
"devDependencies": {
"name": "stryker-mocha-runner",
"version": "0.16.0",
"description": "A plugin to use the mocha test runner in Stryker, the JavaScript mutation testing framework",
"main": "src/index.js",
"repository": {
"type": "git",
"url": "https://github.com/stryker-mutator/stryker"
},
"engines": {
"node": ">=6"
},
"keywords": [
"stryker",
"stryker-plugin",
"mocha",
"stryker-test-runner"
],
"author": "Simon de Lang <[email protected]>",
"contributors": [
"Nico Jansen <[email protected]>",
"Simon de Lang <[email protected]>"
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/stryker-mutator/stryker/issues"
},
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/stryker-mocha-runner#readme",
"dependencies": {
"multimatch": "~3.0.0",
"tslib": "~1.9.3"
},
"devDependencies": {
"@stryker-mutator/test-helpers": "0.0.0",
"@types/multimatch": "~2.1.2",
"@types/multimatch": "~2.1.2",
"stryker-api": "^0.23.0",
"stryker-mocha-framework": "^0.14.0"
},
"peerDependencies": {
"mocha": ">= 2.3.3 < 6",
"stryker-api": ">=0.18.0 <0.24.0"
}
},
"peerDependencies": {
"mocha": ">= 2.3.3 < 6",
"stryker-api": ">=0.18.0 <0.24.0"
}
}
2 changes: 1 addition & 1 deletion packages/stryker-mocha-runner/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TestRunnerFactory } from 'stryker-api/test_runner';
import { declareFactoryPlugin, PluginKind, BaseContext, tokens, commonTokens, Injector } from 'stryker-api/plugin';
import { declareFactoryPlugin, Injector, PluginKind, BaseContext, tokens, commonTokens } from 'stryker-api/plugin';

import MochaTestRunner from './MochaTestRunner';
import MochaConfigEditor from './MochaConfigEditor';
Expand Down
4 changes: 3 additions & 1 deletion packages/stryker/src/Stryker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ export default class Stryker {
this.injector = configEditorInjector
.provideValue(commonTokens.config, this.config)
.provideValue(commonTokens.options, this.config as StrykerOptions);
this.testFramework = this.injector
.provideFactory(coreTokens.pluginCreatorTestFramework, PluginCreator.createFactory(PluginKind.TestFramework))
.injectClass(TestFrameworkOrchestrator).determineTestFramework();
this.reporter = this.injector
.provideFactory(coreTokens.pluginCreatorReporter, PluginCreator.createFactory(PluginKind.Reporter))
.injectClass(BroadcastReporter);
this.testFramework = new TestFrameworkOrchestrator(this.config).determineTestFramework();
new ConfigValidator(this.config, this.testFramework).validate();
}

Expand Down
Loading

0 comments on commit a7160f4

Please sign in to comment.