Skip to content

Commit

Permalink
fix(karma-runner): support zero-mutant runs (#3787)
Browse files Browse the repository at this point in the history
Fix a bug that blocked users from performing a run without mutating files.
  • Loading branch information
bodote committed Oct 19, 2022
1 parent f0e519b commit c6a9219
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ To run local changes you made in StrykerJS in an actual project you have two opt
```sh
cd my-project
open stryker.conf.json
# Add `"plugins": ["/home/username/stryker-js/packages/jest-runner"]` inside the stryker.conf.json
# Add `"plugins": ["/home/username/stryker-js/packages/karma-runner/dist/src/index.js"]` inside the stryker.conf.json
# If you use typescript checker and you get an error : Cannot find Checker plugin "typescript"
# then add the typescript checker local path to the `plugin` as well:
# "plugins": ["/Users/username/stryker-js/packages/karma-runner/dist/src/index.js", "/Users/username/stryker-js/packages/typescript-checker/dist/src/index.js"],
/home/username/stryker-js/packages/core/bin/stryker run
```
This way you can also debug from vscode using the "Attach" configuration and running Stryker from `my-project` like this: `node --inspect-brk /home/username/stryker-js/packages/core/bin/stryker run`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,20 @@ export class TestHooksMiddleware {
}

private configurePerTestCoverageAnalysis() {
this.currentTestHooks = `
window.${SHOULD_REPORT_COVERAGE_FLAG} = true;
window.${NAMESPACE} = window.${NAMESPACE} || {};`;
switch (this.testFramework) {
case 'jasmine':
this.currentTestHooks = `
window.${SHOULD_REPORT_COVERAGE_FLAG} = true;
this.currentTestHooks += `
jasmine.getEnv().addReporter({
specStarted: function (spec) {
window.${NAMESPACE}.${CURRENT_TEST_ID} = spec.id;
}
});`;
break;
case 'mocha':
this.currentTestHooks = `
window.${SHOULD_REPORT_COVERAGE_FLAG} = true;
this.currentTestHooks += `
beforeEach(function() {
window.${NAMESPACE}.${CURRENT_TEST_ID} = this.currentTest && this.currentTest.fullTitle();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe(TestHooksMiddleware.name, () => {
expect(sut.currentTestHooks)
.contains('window.__strykerShouldReportCoverage__ = true')
.contains('window.__stryker__.currentTestId = spec.id')
.contains('window.__stryker__ = window.__stryker__ || {};')
.and.contains('jasmine.getEnv().addReporter(')
.and.not.contains('beforeEach(function() {');
});
Expand All @@ -48,6 +49,7 @@ describe(TestHooksMiddleware.name, () => {
expect(sut.currentTestHooks)
.contains('window.__strykerShouldReportCoverage__ = true')
.contains('window.__stryker__.currentTestId = this.currentTest && this.currentTest.fullTitle()')
.contains('window.__stryker__ = window.__stryker__ || {};')
.and.contains('beforeEach(function() {')
.and.not.contains('jasmine.getEnv().addReporter(');
});
Expand Down

0 comments on commit c6a9219

Please sign in to comment.