UNPKG

@stryker-mutator/core

Version:

The extendable JavaScript mutation testing framework

45 lines 1.86 kB
import { commonTokens, PluginKind, tokens } from '@stryker-mutator/api/plugin'; import { DryRunStatus, MutantRunStatus, } from '@stryker-mutator/api/test-runner'; import { errorToString } from '@stryker-mutator/util'; import { coreTokens } from '../di/index.js'; export class ChildProcessTestRunnerWorker { underlyingTestRunner; static inject = tokens(commonTokens.options, coreTokens.pluginCreator); constructor({ testRunner }, pluginCreator) { this.underlyingTestRunner = pluginCreator.create(PluginKind.TestRunner, testRunner); } async capabilities() { return this.underlyingTestRunner.capabilities(); } async init() { if (this.underlyingTestRunner.init) { await this.underlyingTestRunner.init(); } } async dispose() { if (this.underlyingTestRunner.dispose) { await this.underlyingTestRunner.dispose(); } } async dryRun(options) { const dryRunResult = await this.underlyingTestRunner.dryRun(options); if (dryRunResult.status === DryRunStatus.Complete && !dryRunResult.mutantCoverage && options.coverageAnalysis !== 'off') { // @ts-expect-error global __mutantCoverage__ isn't statically typed dryRunResult.mutantCoverage = global.__mutantCoverage__; } if (dryRunResult.status === DryRunStatus.Error) { dryRunResult.errorMessage = errorToString(dryRunResult.errorMessage); } return dryRunResult; } async mutantRun(options) { const result = await this.underlyingTestRunner.mutantRun(options); if (result.status === MutantRunStatus.Error) { result.errorMessage = errorToString(result.errorMessage); } return result; } } //# sourceMappingURL=child-process-test-runner-worker.js.map