-
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(mocha-runner): support mocha 8 (#2259)
* Support peer dependency range mocha@<9 * Add support for [rootHooks](mochajs/mocha#4244) * Ignore `--parallel` flag (stryker will handle concurrency).
- Loading branch information
Showing
21 changed files
with
2,635 additions
and
3,394 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"require": "./test/helpers/testSetup.js", | ||
"spec": ["test/unit/*.js"] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
exports.mochaHooks = { | ||
beforeAll() { | ||
global.expect = require('chai').expect; | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
e2e/test/mocha-mocha/test/AddSpec.js → e2e/test/mocha-mocha/test/unit/AddSpec.js
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
3 changes: 1 addition & 2 deletions
3
e2e/test/mocha-mocha/test/CircleSpec.js → e2e/test/mocha-mocha/test/unit/CircleSpec.js
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 |
---|---|---|
|
@@ -50,6 +50,6 @@ | |
}, | ||
"peerDependencies": { | ||
"@stryker-mutator/core": "^3.0.0", | ||
"mocha": ">= 2.3.3 < 8" | ||
"mocha": ">= 2.3.3 < 9" | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
packages/mocha-runner/test/integration/ProjectWithRootHooks.it.spec.ts
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as path from 'path'; | ||
|
||
import { commonTokens } from '@stryker-mutator/api/plugin'; | ||
import { testInjector } from '@stryker-mutator/test-helpers'; | ||
import { expect } from 'chai'; | ||
import { RunStatus } from '@stryker-mutator/api/test_runner'; | ||
|
||
import { MochaTestRunner } from '../../src/MochaTestRunner'; | ||
import MochaOptionsEditor from '../../src/MochaOptionsEditor'; | ||
import MochaOptionsLoader from '../../src/MochaOptionsLoader'; | ||
|
||
describe('Running a project with root hooks', () => { | ||
const cwd = process.cwd(); | ||
|
||
let sut: MochaTestRunner; | ||
|
||
beforeEach(async () => { | ||
process.chdir(path.resolve(__dirname, '..', '..', 'testResources', 'parallel-with-root-hooks-sample')); | ||
testInjector.injector.provideClass('loader', MochaOptionsLoader).injectClass(MochaOptionsEditor).edit(testInjector.options); | ||
sut = testInjector.injector.provideValue(commonTokens.sandboxFileNames, []).injectClass(MochaTestRunner); | ||
await sut.init(); | ||
}); | ||
|
||
afterEach(() => { | ||
process.chdir(cwd); | ||
}); | ||
|
||
it('should have run the root hooks', async () => { | ||
const result = await sut.run({}); | ||
expect(result.status).eq(RunStatus.Complete); | ||
expect(result.tests).has.lengthOf(2); | ||
expect(result.errorMessages).lengthOf(0); | ||
}); | ||
}); |
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
6 changes: 6 additions & 0 deletions
6
packages/mocha-runner/testResources/parallel-with-root-hooks-sample/.mocharc.jsonc
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"ui": "bdd", | ||
"parallel": true, | ||
"require": "./test/setup.js", | ||
"spec": "test/unit/*.js" | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/mocha-runner/testResources/parallel-with-root-hooks-sample/test/setup.js
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
exports.mochaHooks = { | ||
beforeEach() { | ||
global.add = (a, b) => a + b; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/mocha-runner/testResources/parallel-with-root-hooks-sample/test/unit/spec.js
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const assert = require('assert'); | ||
|
||
describe('add', () => { | ||
it('should add 1 + 1 = 2', () => { | ||
assert.equal(add(1, 1), 2); | ||
}); | ||
}) | ||
|
7 changes: 7 additions & 0 deletions
7
packages/mocha-runner/testResources/parallel-with-root-hooks-sample/test/unit/spec2.js
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const assert = require('assert'); | ||
|
||
describe('add also', () => { | ||
it('should add 2 - 3 = -1', () => { | ||
assert.equal(add(2, -3), -1); | ||
}); | ||
}) |