@stryker-mutator/jest-runner
Version:
A plugin to use the jest test runner and framework in Stryker, the JavaScript mutation testing framework
30 lines (26 loc) • 1.04 kB
text/typescript
import { JestRunResult } from '../jest-run-result.js';
import { pluginTokens } from '../plugin-di.js';
import { JestWrapper } from '../utils/jest-wrapper.js';
import { JestTestAdapter, RunSettings } from './jest-test-adapter.js';
export class JestGreaterThan25TestAdapter implements JestTestAdapter {
public static readonly inject = [pluginTokens.jestWrapper] as const;
constructor(private readonly jestWrapper: JestWrapper) {}
public async run({ jestConfig, fileNamesUnderTest, testNamePattern, testLocationInResults }: RunSettings): Promise<JestRunResult> {
const config = JSON.stringify(jestConfig);
const result = await this.jestWrapper.runCLI(
{
$0: 'stryker',
_: fileNamesUnderTest ? fileNamesUnderTest : [],
findRelatedTests: !!fileNamesUnderTest,
config,
runInBand: true,
silent: true,
passWithNoTests: true,
testNamePattern,
testLocationInResults,
},
[jestConfig.rootDir ?? process.cwd()],
);
return result;
}
}