-
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.
Add support for Jest 25, where Jest switched to named exports. Jest versions >22 are now all supported. Fixes #1983
- Loading branch information
1 parent
18bf9b6
commit b45e872
Showing
20 changed files
with
20,542 additions
and
19,934 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 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
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
33 changes: 33 additions & 0 deletions
33
packages/jest-runner/src/jestTestAdapters/JestGreaterThan25Adapter.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,33 @@ | ||
import { Logger } from '@stryker-mutator/api/logging'; | ||
import { commonTokens, tokens } from '@stryker-mutator/api/plugin'; | ||
|
||
import { jestWrapper } from '../utils/jestWrapper'; | ||
|
||
import JestTestAdapter from './JestTestAdapter'; | ||
|
||
export default class JestGreaterThan25Adapter implements JestTestAdapter { | ||
public static inject = tokens(commonTokens.logger); | ||
constructor(private readonly log: Logger) {} | ||
|
||
public async run(jestConfig: Jest.Configuration, projectRoot: string, fileNameUnderTest?: string): Promise<Jest.RunResult> { | ||
jestConfig.reporters = []; | ||
const config = JSON.stringify(jestConfig); | ||
this.log.trace(`Invoking Jest with config ${config}`); | ||
if (fileNameUnderTest) { | ||
this.log.trace(`Only running tests related to ${fileNameUnderTest}`); | ||
} | ||
|
||
const result = await jestWrapper.runCLI( | ||
{ | ||
$0: 'stryker', | ||
_: fileNameUnderTest ? [fileNameUnderTest] : [], | ||
findRelatedTests: !!fileNameUnderTest, | ||
config, | ||
runInBand: true, | ||
silent: true | ||
}, | ||
[projectRoot] | ||
); | ||
return result; | ||
} | ||
} |
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,5 +1,3 @@ | ||
import jest from 'jest'; | ||
|
||
export default interface JestTestAdapter { | ||
run(config: object, projectRoot: string, fileNameUnderTest?: string): Promise<jest.RunResult>; | ||
run(config: object, projectRoot: string, fileNameUnderTest?: string): Promise<Jest.RunResult>; | ||
} |
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,15 +1,13 @@ | ||
import jest from 'jest'; | ||
|
||
const resolveCreateJestConfig = (path: string, loader?: NodeRequire): Function => { | ||
loader = loader || /* istanbul ignore next */ require; | ||
|
||
return loader(path); | ||
}; | ||
|
||
export function createReactJestConfig(resolve: Function, projectRoot: string, ejected: boolean, loader?: NodeRequire): jest.Configuration { | ||
export function createReactJestConfig(resolve: Function, projectRoot: string, ejected: boolean, loader?: NodeRequire): Jest.Configuration { | ||
return resolveCreateJestConfig('react-scripts/scripts/utils/createJestConfig', loader)(resolve, projectRoot, ejected); | ||
} | ||
|
||
export function createReactTsJestConfig(resolve: Function, projectRoot: string, ejected: boolean, loader?: NodeRequire): jest.Configuration { | ||
export function createReactTsJestConfig(resolve: Function, projectRoot: string, ejected: boolean, loader?: NodeRequire): Jest.Configuration { | ||
return resolveCreateJestConfig('react-scripts-ts/scripts/utils/createJestConfig', loader)(resolve, projectRoot, ejected); | ||
} |
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,12 @@ | ||
import * as jest from 'jest'; | ||
|
||
/** | ||
* Direct stubbing on jest is no longer possible since jest > 25 | ||
*/ | ||
class JestWrapper { | ||
public runCLI: typeof jest.runCLI = (...args) => { | ||
return jest.runCLI(...args); | ||
}; | ||
} | ||
|
||
export const jestWrapper = new JestWrapper(); |
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
Oops, something went wrong.