UNPKG

@stryker-mutator/jest-runner

Version:

A plugin to use the jest test runner and framework in Stryker, the JavaScript mutation testing framework

52 lines 2.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mixinJestEnvironment = void 0; const messaging_cjs_1 = require("./messaging.cjs"); function fullNameDescribeBlock(describe) { if (describe.parent) { const parentName = fullNameDescribeBlock(describe.parent); return `${parentName} ${describe.name}`.trimStart(); } else { return ''; // describe.name === "ROOT_DESCRIBE_BLOCK" } } function fullName(test) { const suiteName = fullNameDescribeBlock(test.parent); return `${suiteName} ${test.name}`.trimStart(); } const STRYKER_JEST_ENV = Symbol('StrykerJestEnvironment'); function mixinJestEnvironment(JestEnvironmentClass) { var _a; if (JestEnvironmentClass[STRYKER_JEST_ENV]) { return JestEnvironmentClass; } else { class StrykerJestEnvironment extends JestEnvironmentClass { constructor(config, context) { var _b; super(config, context); this.handleTestEvent = async (event, eventState) => { var _b; // eslint-disable-next-line @typescript-eslint/no-unsafe-argument await ((_b = super.handleTestEvent) === null || _b === void 0 ? void 0 : _b.call(this, event, eventState)); if (messaging_cjs_1.state.coverageAnalysis === 'perTest') { if (event.name === 'test_start') { this.strykerContext.currentTestId = fullName(event.test); } else if (event.name === 'test_done') { this.strykerContext.currentTestId = undefined; } } }; this.strykerContext = this.global[(_b = this.global.__strykerGlobalNamespace__) !== null && _b !== void 0 ? _b : '__stryker__'] = messaging_cjs_1.state.instrumenterContext; messaging_cjs_1.state.testFilesWithStrykerEnvironment.add(context.testPath); } } _a = STRYKER_JEST_ENV; StrykerJestEnvironment[_a] = true; return StrykerJestEnvironment; } } exports.mixinJestEnvironment = mixinJestEnvironment; //# sourceMappingURL=mixin-jest-environment.cjs.map