-
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.
fix(jest-runner): allow a different rootDir
The Jest Runner now adhers to the way Jest deremines the [rootDir](https://jestjs.io/docs/configuration#rootdir-string).
- Loading branch information
Showing
16 changed files
with
100 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"testEnvironment": "node", | ||
"testMatch": ["**/jest-spec/*.spec.js"] | ||
"rootDir": "..", | ||
"testMatch": ["<rootDir>/jest-spec/*.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
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,4 +1,3 @@ | ||
export * from './create-react-jest-config'; | ||
export * from './verify-all-test-files-have-coverage'; | ||
export * from './merge-mutant-coverage'; | ||
export * from './jest-wrapper'; |
27 changes: 27 additions & 0 deletions
27
packages/jest-runner/test/integration/config-in-child-dir.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,27 @@ | ||
import { commonTokens } from '@stryker-mutator/api/plugin'; | ||
import { assertions, factory, testInjector } from '@stryker-mutator/test-helpers'; | ||
import { expect } from 'chai'; | ||
|
||
import { JestOptions } from '../../src-generated/jest-runner-options'; | ||
import { JestRunnerOptionsWithStrykerOptions } from '../../src/jest-runner-options-with-stryker-options'; | ||
import { jestTestRunnerFactory } from '../../src/jest-test-runner'; | ||
import { createJestOptions } from '../helpers/producers'; | ||
|
||
import { resolveTestResource } from '../helpers/resolve-test-resource'; | ||
|
||
describe('jest with config in child dir', () => { | ||
function createSut(overrides?: Partial<JestOptions>) { | ||
const options: JestRunnerOptionsWithStrykerOptions = factory.strykerWithPluginOptions({ | ||
jest: createJestOptions(overrides), | ||
}); | ||
return testInjector.injector.provideValue(commonTokens.options, options).injectFunction(jestTestRunnerFactory); | ||
} | ||
|
||
it('should still be able perform a mutant run', async () => { | ||
process.chdir(resolveTestResource('config-in-child-dir')); | ||
const sut = createSut({ configFile: 'client/jest.config.js' }); | ||
const actual = await sut.dryRun(factory.dryRunOptions()); | ||
assertions.expectCompleted(actual); | ||
expect(actual.tests).lengthOf(2); | ||
}); | ||
}); |
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
40 changes: 0 additions & 40 deletions
40
packages/jest-runner/test/unit/utils/create-react-jest-config.spec.ts
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
packages/jest-runner/testResources/config-in-child-dir/client/jest.config.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 project = "client" | ||
const prefix = "<rootDir>/../" | ||
|
||
module.exports = { | ||
testEnvironment: "node", | ||
testMatch: [prefix + project + "/**/*.test.js"], | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/jest-runner/testResources/config-in-child-dir/client/src/sum.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 @@ | ||
function sum(a, b) { | ||
return a + b; | ||
} | ||
function sub(a, b) { | ||
return a - b; | ||
} | ||
exports.sum = sum; | ||
exports.sub = sub; |
8 changes: 8 additions & 0 deletions
8
packages/jest-runner/testResources/config-in-child-dir/client/src/sum.test.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 {sum, sub} = require('./sum'); | ||
|
||
test('adds 1 + 2 to equal 3', () => { | ||
expect(sum(1, 2)).toBe(3); | ||
}); | ||
test('sub 1 - 0 to equal 1', () => { | ||
expect(sub(1, 0)).toBe(1); | ||
}); |