-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config-editors): Remove side effects from all config editor plug…
…ins (#1317) Load all config editor plugins via new plugin mechanism. Migrate the existing config editors to new plugin mechanism. * `JestConfigEditor` * `MochaRunnerConfigEditor` * `TypeScriptConfigEditor`
- Loading branch information
Showing
43 changed files
with
227 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { ConfigEditorFactory } from 'stryker-api/config'; | ||
import { PluginKind, declareClassPlugin } from 'stryker-api/plugin'; | ||
import { TestRunnerFactory } from 'stryker-api/test_runner'; | ||
import JestConfigEditor from './JestConfigEditor'; | ||
import JestTestRunner from './JestTestRunner'; | ||
|
||
process.env.BABEL_ENV = 'test'; | ||
|
||
ConfigEditorFactory.instance().register('jest', JestConfigEditor); | ||
export const strykerPlugins = [ | ||
declareClassPlugin(PluginKind.ConfigEditor, 'jest', JestConfigEditor) | ||
]; | ||
TestRunnerFactory.instance().register('jest', JestTestRunner); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import * as sinon from 'sinon'; | ||
import { testInjector } from '@stryker-mutator/test-helpers'; | ||
|
||
afterEach(() => { | ||
sinon.restore(); | ||
testInjector.reset(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ | |
"references": [ | ||
{ | ||
"path": "./tsconfig.src.json" | ||
}, | ||
{ | ||
"path": "../stryker-test-helpers/tsconfig.src.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import { ConfigEditor, Config } from 'stryker-api/config'; | ||
import { mochaOptionsKey } from './MochaRunnerOptions'; | ||
import MochaOptionsLoader from './MochaOptionsLoader'; | ||
import { tokens } from 'stryker-api/plugin'; | ||
|
||
export default class MochaConfigEditor implements ConfigEditor { | ||
|
||
public static inject = tokens('loader'); | ||
constructor(private readonly loader: MochaOptionsLoader) {} | ||
|
||
public edit(config: Config): void { | ||
config[mochaOptionsKey] = new MochaOptionsLoader().load(config); | ||
config[mochaOptionsKey] = this.loader.load(config); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
import { TestRunnerFactory } from 'stryker-api/test_runner'; | ||
import { ConfigEditorFactory } from 'stryker-api/config'; | ||
import { declareFactoryPlugin, PluginKind, BaseContext, tokens, commonTokens, Injector } from 'stryker-api/plugin'; | ||
|
||
import MochaTestRunner from './MochaTestRunner'; | ||
import MochaConfigEditor from './MochaConfigEditor'; | ||
import MochaOptionsLoader from './MochaOptionsLoader'; | ||
|
||
TestRunnerFactory.instance().register('mocha', MochaTestRunner); | ||
ConfigEditorFactory.instance().register('mocha-runner', MochaConfigEditor); | ||
|
||
export const strykerPlugins = [ | ||
declareFactoryPlugin(PluginKind.ConfigEditor, 'mocha-runner', mochaConfigEditorFactory) | ||
]; | ||
|
||
mochaConfigEditorFactory.inject = tokens(commonTokens.injector); | ||
function mochaConfigEditorFactory(injector: Injector<BaseContext>): MochaConfigEditor { | ||
return injector | ||
.provideClass('loader', MochaOptionsLoader) | ||
.injectClass(MochaConfigEditor); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import * as sinon from 'sinon'; | ||
|
||
beforeEach(() => { | ||
global.sandbox = sinon.createSandbox(); | ||
}); | ||
import { testInjector } from '@stryker-mutator/test-helpers'; | ||
|
||
afterEach(() => { | ||
global.sandbox.restore(); | ||
sinon.restore(); | ||
testInjector.reset(); | ||
}); |
Oops, something went wrong.