From 864280afa39bbe77ca52ec1528d5bdc77e0fb1a1 Mon Sep 17 00:00:00 2001 From: Hugo van Rijswijk Date: Thu, 16 Nov 2023 23:59:19 +0100 Subject: [PATCH] chore(deps): update mutation-testing-elements to v3.0.0 --- e2e/package.json | 4 +- e2e/test/hit-limit/verify/verify.js | 3 +- e2e/test/ignore-project/verify/verify.js | 12 ++-- .../test/unit/helpers/factory.ts | 2 +- package-lock.json | 32 +++++----- packages/api/package.json | 4 +- packages/api/src/core/mutant.ts | 4 +- packages/core/package.json | 6 +- .../core/src/mutants/incremental-differ.ts | 6 +- .../core/src/mutants/mutant-test-planner.ts | 2 +- .../src/process/4-mutation-test-executor.ts | 4 +- .../core/src/reporters/clear-text-reporter.ts | 22 +++---- packages/core/src/reporters/dots-reporter.ts | 10 +-- .../reporters/mutation-test-report-helper.ts | 10 +-- .../core/src/reporters/progress-keeper.ts | 6 +- packages/core/src/utils/string-utils.ts | 18 +++--- .../reporters/html/simple-report.ts | 6 +- .../unit/mutants/incremental-differ.spec.ts | 64 +++++++++---------- .../unit/mutants/mutant-test-planner.spec.ts | 14 ++-- .../process/4-mutation-test-executor.spec.ts | 8 +-- .../reporters/clear-text-reporter.spec.ts | 40 ++++++------ .../dashboard-reporter.spec.ts | 10 +-- .../test/unit/reporters/dots-reporter.spec.ts | 3 +- .../mutation-test-report-helper.spec.ts | 54 ++++++++-------- .../unit/reporters/progress-keeper.spec.ts | 3 +- packages/instrumenter/src/mutant.ts | 4 +- .../instrumenter/test/unit/mutant.spec.ts | 4 +- packages/test-helpers/package.json | 2 +- packages/test-helpers/src/factory.ts | 23 ++++--- 29 files changed, 183 insertions(+), 197 deletions(-) diff --git a/e2e/package.json b/e2e/package.json index b73184f189..a3c54ef56d 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -46,8 +46,8 @@ "karma-webpack": "5.0.0", "minimatch": "9.0.3", "mocha": "10.2.0", - "mutation-testing-metrics": "2.0.5", - "mutation-testing-report-schema": "2.0.5", + "mutation-testing-metrics": "3.0.0", + "mutation-testing-report-schema": "3.0.0", "rxjs": "7.8.1", "semver": "7.5.4", "svelte": "4.2.3", diff --git a/e2e/test/hit-limit/verify/verify.js b/e2e/test/hit-limit/verify/verify.js index e6b479d35e..d8a63dfdee 100644 --- a/e2e/test/hit-limit/verify/verify.js +++ b/e2e/test/hit-limit/verify/verify.js @@ -1,6 +1,5 @@ import { expect } from 'chai'; import { Stryker } from '@stryker-mutator/core'; -import { MutantStatus } from 'mutation-testing-report-schema/api'; describe('Limit counter', () => { /** @@ -11,7 +10,7 @@ describe('Limit counter', () => { (only ? it.only : it)(`should limit infinite loops in the ${runner}-runner`, async () => { const stryker = new Stryker({ testRunner: runner }); const results = await stryker.runMutationTest(); - const timeoutResults = results.filter((res) => res.status === MutantStatus.Timeout); + const timeoutResults = results.filter((res) => res.status === 'Timeout'); expect(timeoutResults).lengthOf(3); timeoutResults.forEach((result) => expect(result.statusReason).eq('Hit limit reached (501/500)')); }); diff --git a/e2e/test/ignore-project/verify/verify.js b/e2e/test/ignore-project/verify/verify.js index b90ebc8321..f74b44213d 100644 --- a/e2e/test/ignore-project/verify/verify.js +++ b/e2e/test/ignore-project/verify/verify.js @@ -19,15 +19,15 @@ describe('After running stryker on jest-react project', () => { expect(conditionalExpressionMutants).lengthOf(3); expect(equalityOperatorMutants).lengthOf(2); booleanLiteralMutants.forEach((booleanMutant) => { - expect(booleanMutant.status).eq(MutantStatus.Ignored); + expect(booleanMutant.status).eq('Ignored'); expect(booleanMutant.statusReason).eq('Ignore boolean and conditions'); }); conditionalExpressionMutants.forEach((conditionalMutant) => { - expect(conditionalMutant.status).eq(MutantStatus.Ignored); + expect(conditionalMutant.status).eq('Ignored'); expect(conditionalMutant.statusReason).eq('Ignore boolean and conditions'); }); equalityOperatorMutants.forEach((equalityMutant) => { - expect(equalityMutant.status).eq(MutantStatus.NoCoverage); + expect(equalityMutant.status).eq('NoCoverage'); }); }); @@ -37,7 +37,7 @@ describe('After running stryker on jest-react project', () => { const mutantsAtLine3 = circleResult.mutants.filter(({ location }) => location.start.line === 3); expect(mutantsAtLine3).lengthOf(2); mutantsAtLine3.forEach((mutant) => { - expect(mutant.status).eq(MutantStatus.Ignored); + expect(mutant.status).eq('Ignored'); expect(mutant.statusReason).eq('Ignored because of excluded mutation "ArithmeticOperator"'); }); }); @@ -55,9 +55,9 @@ describe('After running stryker on jest-react project', () => { expect(mutantsAtLin13).lengthOf(1); expect(mutantsAtLine18).lengthOf(1); [...mutantsAtLine2, ...mutantsAtLin8, ...mutantsAtLin13].forEach((mutant) => { - expect(mutant.status).eq(MutantStatus.Ignored); + expect(mutant.status).eq('Ignored'); expect(mutant.statusReason).eq("We're not interested in console.log statements for now"); }); - mutantsAtLine18.forEach((mutant) => expect(mutant.status).eq(MutantStatus.NoCoverage)); + mutantsAtLine18.forEach((mutant) => expect(mutant.status).eq('NoCoverage')); }); }); diff --git a/e2e/test/karma-webpack-with-ts/test/unit/helpers/factory.ts b/e2e/test/karma-webpack-with-ts/test/unit/helpers/factory.ts index 34fba712f8..00a888c8d4 100644 --- a/e2e/test/karma-webpack-with-ts/test/unit/helpers/factory.ts +++ b/e2e/test/karma-webpack-with-ts/test/unit/helpers/factory.ts @@ -16,7 +16,7 @@ export function createMutantResult(overrides?: Partial): MutantRes }, mutatorName: 'bazMutator', replacement: 'baz', - status: MutantStatus.Killed, + status: 'Killed', }; return { ...defaults, ...overrides }; } diff --git a/package-lock.json b/package-lock.json index f32a5e81a1..839ec2e4fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17042,22 +17042,22 @@ } }, "node_modules/mutation-testing-elements": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/mutation-testing-elements/-/mutation-testing-elements-2.0.5.tgz", - "integrity": "sha512-O/idiNrmh8bjdw6NeMtd7Eg3oPU90C2qIDJ1e7lr8E9p6WI3obpY03AGJA/OR6a+zZqYYepsYe9rdrHFTcZIxQ==" + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mutation-testing-elements/-/mutation-testing-elements-3.0.1.tgz", + "integrity": "sha512-hsBKkabjD2sjyR2vhdEFPDxZfYLw71geIWjEh4rcZSSQAtyWRfjGf6UbdMjleuyw1ZZTgGt6CImtwRY7s3lrVg==" }, "node_modules/mutation-testing-metrics": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/mutation-testing-metrics/-/mutation-testing-metrics-2.0.5.tgz", - "integrity": "sha512-4cLfXDw1mv4P4dLrtVWF6sA7Az8nFli0j4j65ze950fgijSbRPk2r6RvBNCTuoR2PcdKjtrAku9DZTObBWc8xw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mutation-testing-metrics/-/mutation-testing-metrics-3.0.0.tgz", + "integrity": "sha512-WslGuCdpqT+6SpeIahMhLrJl5+YbutlOCFKxuULIkAkaHfsWBK8UCq6euE7PiDEx+R1pYZo//kqRbFIOFmdQug==", "dependencies": { - "mutation-testing-report-schema": "2.0.5" + "mutation-testing-report-schema": "3.0.0" } }, "node_modules/mutation-testing-report-schema": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/mutation-testing-report-schema/-/mutation-testing-report-schema-2.0.5.tgz", - "integrity": "sha512-F/+HALtQbiiO8hJX4TkOdGtnEfErNpxKCiMUEIJ1x50YYSgrO1o5Z3dIwHHU7fXpsephEuNooQxPxTWPIs+7qg==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mutation-testing-report-schema/-/mutation-testing-report-schema-3.0.0.tgz", + "integrity": "sha512-70+ZPYoyedruSGiEcXQnFiTtIusBYlsL/2EMwfR+/HOqBGxBpmI798spqc86ZVYXPVCL5mt2rWjE1dTQwcjpmQ==" }, "node_modules/mute-stream": { "version": "0.0.8", @@ -25043,8 +25043,8 @@ "version": "7.3.0", "license": "Apache-2.0", "dependencies": { - "mutation-testing-metrics": "2.0.5", - "mutation-testing-report-schema": "2.0.5", + "mutation-testing-metrics": "3.0.0", + "mutation-testing-report-schema": "3.0.0", "tslib": "~2.6.0", "typed-inject": "~4.0.0" }, @@ -25076,9 +25076,9 @@ "lodash.groupby": "~4.6.0", "log4js": "~6.9.0", "minimatch": "~9.0.1", - "mutation-testing-elements": "2.0.5", - "mutation-testing-metrics": "2.0.5", - "mutation-testing-report-schema": "2.0.5", + "mutation-testing-elements": "3.0.1", + "mutation-testing-metrics": "3.0.0", + "mutation-testing-report-schema": "3.0.0", "npm-run-path": "~5.1.0", "progress": "~2.0.0", "rxjs": "~7.8.0", @@ -25498,7 +25498,7 @@ "dependencies": { "ajv": "~8.12.0", "flatted": "~3.2.5", - "mutation-testing-metrics": "2.0.5", + "mutation-testing-metrics": "3.0.0", "rxjs": "~7.8.0" }, "devDependencies": { diff --git a/packages/api/package.json b/packages/api/package.json index cccee672a4..e45a0ddc3c 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -57,8 +57,8 @@ "node": ">=16.0.0" }, "dependencies": { - "mutation-testing-metrics": "2.0.5", - "mutation-testing-report-schema": "2.0.5", + "mutation-testing-metrics": "3.0.0", + "mutation-testing-report-schema": "3.0.0", "tslib": "~2.6.0", "typed-inject": "~4.0.0" }, diff --git a/packages/api/src/core/mutant.ts b/packages/api/src/core/mutant.ts index 90819ba42b..a56fa26dcf 100644 --- a/packages/api/src/core/mutant.ts +++ b/packages/api/src/core/mutant.ts @@ -1,6 +1,6 @@ import * as schema from 'mutation-testing-report-schema/api'; -export { MutantStatus } from 'mutation-testing-report-schema/api'; +export type { MutantStatus } from 'mutation-testing-report-schema/api'; // We're reusing the `MutantResult` interface here to acquire uniformity. @@ -21,7 +21,7 @@ export interface Mutant */ replacement: string; /** - * The status if a mutant if known. This should be undefined for a mutant that still needs testing. + * The status of a mutant if known. This should be undefined for a mutant that still needs testing. */ status?: schema.MutantStatus; } diff --git a/packages/core/package.json b/packages/core/package.json index 7a3f4b0fa6..a7144b301e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -84,9 +84,9 @@ "lodash.groupby": "~4.6.0", "log4js": "~6.9.0", "minimatch": "~9.0.1", - "mutation-testing-elements": "2.0.5", - "mutation-testing-metrics": "2.0.5", - "mutation-testing-report-schema": "2.0.5", + "mutation-testing-elements": "3.0.1", + "mutation-testing-metrics": "3.0.0", + "mutation-testing-report-schema": "3.0.0", "npm-run-path": "~5.1.0", "progress": "~2.0.0", "rxjs": "~7.8.0", diff --git a/packages/core/src/mutants/incremental-differ.ts b/packages/core/src/mutants/incremental-differ.ts index fcc0fde526..67ce35f619 100644 --- a/packages/core/src/mutants/incremental-differ.ts +++ b/packages/core/src/mutants/incremental-differ.ts @@ -2,7 +2,7 @@ import path from 'path'; import { diff_match_patch as DiffMatchPatch } from 'diff-match-patch'; import chalk from 'chalk'; -import { schema, Mutant, Position, Location, MutantStatus, StrykerOptions, FileDescriptions, MutateDescription } from '@stryker-mutator/api/core'; +import { schema, Mutant, Position, Location, StrykerOptions, FileDescriptions, MutateDescription } from '@stryker-mutator/api/core'; import { Logger } from '@stryker-mutator/api/logging'; import { TestResult, TestStatus } from '@stryker-mutator/api/test-runner'; import { I, normalizeFileName, normalizeLineEndings, notEmpty } from '@stryker-mutator/util'; @@ -302,13 +302,13 @@ export class IncrementalDiffer { // End users can use --force to force retesting of certain mutants return true; } - if (oldMutant.status === MutantStatus.Ignored) { + if (oldMutant.status === 'Ignored') { // Was previously ignored, but not anymore, we need to run it now return false; } const testsDiff = diffTestCoverage(mutant.id, oldCoverageTestKeysByMutantKey.get(mutantKey), coveringTests); - if (oldMutant.status === MutantStatus.Killed) { + if (oldMutant.status === 'Killed') { if (oldKillingTests) { for (const killingTest of oldKillingTests) { if (testsDiff.get(killingTest) === 'same') { diff --git a/packages/core/src/mutants/mutant-test-planner.ts b/packages/core/src/mutants/mutant-test-planner.ts index 9b16eb6b91..9b2824ca00 100644 --- a/packages/core/src/mutants/mutant-test-planner.ts +++ b/packages/core/src/mutants/mutant-test-planner.ts @@ -87,7 +87,7 @@ export class MutantTestPlanner { } else if (this.options.ignoreStatic) { // Static (w/o perTest coverage) and ignoreStatic is on -> Ignore. return this.createMutantEarlyResultPlan(mutant, { - status: MutantStatus.Ignored, + status: 'Ignored', statusReason: 'Static mutant (and "ignoreStatic" was enabled)', isStatic, coveredBy, diff --git a/packages/core/src/process/4-mutation-test-executor.ts b/packages/core/src/process/4-mutation-test-executor.ts index 90da0d9b1e..d2faea9928 100644 --- a/packages/core/src/process/4-mutation-test-executor.ts +++ b/packages/core/src/process/4-mutation-test-executor.ts @@ -1,7 +1,7 @@ import { from, partition, merge, Observable, lastValueFrom, EMPTY, concat, bufferTime, mergeMap } from 'rxjs'; import { toArray, map, shareReplay, tap } from 'rxjs/operators'; import { tokens, commonTokens } from '@stryker-mutator/api/plugin'; -import { MutantResult, MutantStatus, Mutant, StrykerOptions, PlanKind, MutantTestPlan, MutantRunPlan } from '@stryker-mutator/api/core'; +import { MutantResult, Mutant, StrykerOptions, PlanKind, MutantTestPlan, MutantRunPlan } from '@stryker-mutator/api/core'; import { TestRunner, CompleteDryRunResult } from '@stryker-mutator/api/test-runner'; import { Logger } from '@stryker-mutator/api/logging'; import { I } from '@stryker-mutator/util'; @@ -98,7 +98,7 @@ export class MutationTestExecutor { private executeNoCoverage(input$: Observable) { const [noCoverageMatchedMutant$, coveredMutant$] = partition(input$.pipe(shareReplay()), ({ runOptions }) => runOptions.testFilter?.length === 0); const noCoverageResult$ = noCoverageMatchedMutant$.pipe( - map(({ mutant }) => this.mutationTestReportHelper.reportMutantStatus(mutant, MutantStatus.NoCoverage)), + map(({ mutant }) => this.mutationTestReportHelper.reportMutantStatus(mutant, 'NoCoverage')), ); return { noCoverageResult$, coveredMutant$ }; } diff --git a/packages/core/src/reporters/clear-text-reporter.ts b/packages/core/src/reporters/clear-text-reporter.ts index ef1f048c60..a3020b5afd 100644 --- a/packages/core/src/reporters/clear-text-reporter.ts +++ b/packages/core/src/reporters/clear-text-reporter.ts @@ -12,8 +12,6 @@ import { getEmojiForStatus, plural } from '../utils/string-utils.js'; import { ClearTextScoreTable } from './clear-text-score-table.js'; -const { MutantStatus } = schema; - export class ClearTextReporter implements Reporter { public static inject = tokens(commonTokens.logger, commonTokens.options); constructor( @@ -99,14 +97,14 @@ export class ClearTextReporter implements Reporter { child.file?.mutants.forEach((result) => { totalTests += result.testsCompleted ?? 0; switch (result.status) { - case MutantStatus.Killed: - case MutantStatus.Timeout: - case MutantStatus.RuntimeError: - case MutantStatus.CompileError: + case 'Killed': + case 'Timeout': + case 'RuntimeError': + case 'CompileError': this.reportMutantResult(result, this.writeDebugLine); break; - case MutantStatus.Survived: - case MutantStatus.NoCoverage: + case 'Survived': + case 'NoCoverage': this.reportMutantResult(result, this.writeLine); break; default: @@ -120,7 +118,7 @@ export class ClearTextReporter implements Reporter { } private statusLabel(mutant: MutantModel): string { - const status = MutantStatus[mutant.status]; + const { status } = mutant; return this.options.clearTextReporter.allowEmojis ? `${getEmojiForStatus(status)} ${status}` : status.toString(); } @@ -142,15 +140,15 @@ export class ClearTextReporter implements Reporter { .forEach((line) => { logImplementation(chalk.green('+ ' + line)); }); - if (result.status === MutantStatus.Survived) { + if (result.status === 'Survived') { if (result.static) { logImplementation('Ran all tests for this mutant.'); } else if (result.coveredByTests) { this.logExecutedTests(result.coveredByTests, logImplementation); } - } else if (result.status === MutantStatus.Killed && result.killedByTests?.length) { + } else if (result.status === 'Killed' && result.killedByTests?.length) { logImplementation(`Killed by: ${result.killedByTests[0].name}`); - } else if (result.status === MutantStatus.RuntimeError || result.status === MutantStatus.CompileError) { + } else if (result.status === 'RuntimeError' || result.status === 'CompileError') { logImplementation(`Error message: ${result.statusReason}`); } logImplementation(''); diff --git a/packages/core/src/reporters/dots-reporter.ts b/packages/core/src/reporters/dots-reporter.ts index 30f7777fe2..94912cd8f3 100644 --- a/packages/core/src/reporters/dots-reporter.ts +++ b/packages/core/src/reporters/dots-reporter.ts @@ -2,22 +2,22 @@ import os from 'os'; import chalk from 'chalk'; import { Reporter } from '@stryker-mutator/api/report'; -import { MutantResult, MutantStatus } from '@stryker-mutator/api/core'; +import type { MutantResult } from '@stryker-mutator/api/core'; export class DotsReporter implements Reporter { public onMutantTested(result: MutantResult): void { let toLog: string; switch (result.status) { - case MutantStatus.Killed: + case 'Killed': toLog = '.'; break; - case MutantStatus.Timeout: + case 'Timeout': toLog = chalk.yellow('T'); break; - case MutantStatus.Survived: + case 'Survived': toLog = chalk.bold.red('S'); break; - case MutantStatus.RuntimeError: + case 'RuntimeError': toLog = chalk.yellow('E'); break; default: diff --git a/packages/core/src/reporters/mutation-test-report-helper.ts b/packages/core/src/reporters/mutation-test-report-helper.ts index b9f6c28780..90b0669691 100644 --- a/packages/core/src/reporters/mutation-test-report-helper.ts +++ b/packages/core/src/reporters/mutation-test-report-helper.ts @@ -76,14 +76,14 @@ export class MutationTestReportHelper { case MutantRunStatus.Error: return this.reportOne({ ...mutant, - status: MutantStatus.RuntimeError, + status: 'RuntimeError', statusReason: result.errorMessage, location, }); case MutantRunStatus.Killed: return this.reportOne({ ...mutant, - status: MutantStatus.Killed, + status: 'Killed', testsCompleted: result.nrOfTests, killedBy: result.killedBy, statusReason: result.failureMessage, @@ -92,14 +92,14 @@ export class MutationTestReportHelper { case MutantRunStatus.Timeout: return this.reportOne({ ...mutant, - status: MutantStatus.Timeout, + status: 'Timeout', statusReason: result.reason, location, }); case MutantRunStatus.Survived: return this.reportOne({ ...mutant, - status: MutantStatus.Survived, + status: 'Survived', testsCompleted: result.nrOfTests, location, }); @@ -114,7 +114,7 @@ export class MutationTestReportHelper { private checkStatusToResultStatus(status: Exclude): MutantStatus { switch (status) { case CheckStatus.CompileError: - return MutantStatus.CompileError; + return 'CompileError'; } } diff --git a/packages/core/src/reporters/progress-keeper.ts b/packages/core/src/reporters/progress-keeper.ts index 4d87bc4ecb..8e7e54b982 100644 --- a/packages/core/src/reporters/progress-keeper.ts +++ b/packages/core/src/reporters/progress-keeper.ts @@ -1,4 +1,4 @@ -import { MutantResult, MutantStatus, MutantRunPlan, MutantTestPlan, PlanKind } from '@stryker-mutator/api/core'; +import { MutantResult, MutantRunPlan, MutantTestPlan, PlanKind } from '@stryker-mutator/api/core'; import { DryRunCompletedEvent, MutationTestingPlanReadyEvent, Reporter, RunTiming } from '@stryker-mutator/api/report'; import { TestRunnerCapabilities } from '@stryker-mutator/api/test-runner'; @@ -47,10 +47,10 @@ export abstract class ProgressKeeper implements Reporter { if (ticks !== undefined) { this.progress.tested++; this.progress.ticks += this.ticksByMutantId.get(result.id) ?? 0; - if (result.status === MutantStatus.Survived) { + if (result.status === 'Survived') { this.progress.survived++; } - if (result.status === MutantStatus.Timeout) { + if (result.status === 'Timeout') { this.progress.timedOut++; } } diff --git a/packages/core/src/utils/string-utils.ts b/packages/core/src/utils/string-utils.ts index 9a9a3f55a9..94d201169f 100644 --- a/packages/core/src/utils/string-utils.ts +++ b/packages/core/src/utils/string-utils.ts @@ -4,8 +4,6 @@ import emojiRegex from 'emoji-regex'; const emojiRe = emojiRegex(); -const { MutantStatus } = schema; - export function wrapInClosure(codeFragment: string): string { return ` (function (window) { @@ -38,20 +36,20 @@ export function deserialize(stringified: string): T { export function getEmojiForStatus(status: schema.MutantStatus): string { switch (status) { - case MutantStatus.Killed: + case 'Killed': return '✅'; - case MutantStatus.NoCoverage: + case 'NoCoverage': return '🙈'; - case MutantStatus.Ignored: + case 'Ignored': return '🤥'; - case MutantStatus.Survived: + case 'Survived': return '👽'; - case MutantStatus.Timeout: + case 'Timeout': return '⏰'; - case MutantStatus.Pending: + case 'Pending': return '⌛'; - case MutantStatus.RuntimeError: - case MutantStatus.CompileError: + case 'RuntimeError': + case 'CompileError': return '💥'; } } diff --git a/packages/core/test/integration/reporters/html/simple-report.ts b/packages/core/test/integration/reporters/html/simple-report.ts index a8ba1bf705..bf6439aac2 100644 --- a/packages/core/test/integration/reporters/html/simple-report.ts +++ b/packages/core/test/integration/reporters/html/simple-report.ts @@ -1,4 +1,4 @@ -import { MutantStatus, schema } from '@stryker-mutator/api/core'; +import { schema } from '@stryker-mutator/api/core'; export const simpleReport: schema.MutationTestResult = { files: { @@ -19,7 +19,7 @@ export const simpleReport: schema.MutationTestResult = { }, mutatorName: 'String Literal', replacement: '""', - status: MutantStatus.Survived, + status: 'Survived', }, { id: '1', @@ -35,7 +35,7 @@ export const simpleReport: schema.MutationTestResult = { }, mutatorName: 'Arithmetic Operator', replacement: '-', - status: MutantStatus.Survived, + status: 'Survived', }, ], source: '"use strict";\nfunction add(a, b) {\n return a + b;\n}', diff --git a/packages/core/test/unit/mutants/incremental-differ.spec.ts b/packages/core/test/unit/mutants/incremental-differ.spec.ts index 732a7b3017..2eed7e6340 100644 --- a/packages/core/test/unit/mutants/incremental-differ.spec.ts +++ b/packages/core/test/unit/mutants/incremental-differ.spec.ts @@ -109,7 +109,7 @@ class ScenarioBuilder { public testCoverage = new TestCoverageTestDouble(); public sut?: IncrementalDiffer; - public withMathProjectExample({ mutantState: mutantStatus = MutantStatus.Killed, isStatic = false } = {}): this { + public withMathProjectExample({ mutantState: mutantStatus = 'Killed', isStatic = false } = {}): this { this.mutants.push( createMutant({ id: this.mutantId, fileName: srcAdd, replacement: '-', mutatorName: 'min-replacement', location: loc(1, 11, 1, 12) }), ); @@ -123,7 +123,7 @@ class ScenarioBuilder { mutatorName: 'min-replacement', statusReason: 'Killed by first test', testsCompleted: 1, - status: mutantStatus, + status: mutantStatus as MutantStatus, location: loc(1, 11, 1, 12), }), ], @@ -403,7 +403,7 @@ class ScenarioBuilder { killedBy: ['spec-3'], replacement: '/', testsCompleted: 1, - status: MutantStatus.Killed, + status: 'Killed', location: loc(1, 11, 1, 12), }), ], @@ -466,7 +466,7 @@ describe(IncrementalDiffer.name, () => { replacement: '-', mutatorName: 'min-replacement', location: loc(1, 11, 1, 12), - status: MutantStatus.Killed, + status: 'Killed', statusReason: 'Killed by first test', testsCompleted: 1, }; @@ -485,7 +485,7 @@ describe(IncrementalDiffer.name, () => { it('should not reuse when the mutant was ignored', () => { // Arrange - const actualDiff = new ScenarioBuilder().withMathProjectExample({ mutantState: MutantStatus.Ignored }).act(); + const actualDiff = new ScenarioBuilder().withMathProjectExample({ mutantState: 'Ignored' }).act(); // Assert const [actualMutant] = actualDiff; @@ -501,7 +501,7 @@ describe(IncrementalDiffer.name, () => { .act(); const [actualMutant] = actualDiff; - expect(actualMutant.status).eq(MutantStatus.Killed); + expect(actualMutant.status).eq('Killed'); }); it('should map killedBy and coveredBy to the new test ids if a mutant result is reused', () => { @@ -518,22 +518,22 @@ describe(IncrementalDiffer.name, () => { it("should identify that a mutant hasn't changed if lines got added above", () => { const actualDiff = new ScenarioBuilder().withMathProjectExample().withAddedLinesAboveMutant("import path from 'path';", '', '').act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it("should identify that a mutant hasn't changed if characters got added before", () => { const actualDiff = new ScenarioBuilder().withMathProjectExample().withAddedTextBeforeMutant("/* text added this shouldn't matter */").act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it("should identify that a mutant hasn't changed if lines got removed above", () => { const actualDiff = new ScenarioBuilder().withMathProjectExample().withRemovedLinesAboveMutant('import path from "path";', '').act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it("should identify that a mutant hasn't changed if characters got removed before", () => { const actualDiff = new ScenarioBuilder().withMathProjectExample().withRemovedTextBeforeMutant("/* text removed, this shouldn't matter*/").act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it('should not reuse the status of a mutant in changed text', () => { @@ -543,12 +543,12 @@ describe(IncrementalDiffer.name, () => { it('should reuse the status when there is no test coverage', () => { const actualDiff = new ScenarioBuilder().withMathProjectExample().withoutTestCoverage().act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it('should reuse the status when there is a test with empty file name', () => { const actualDiff = new ScenarioBuilder().withMathProjectExample().withEmptyFileNameTestFile().act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it('should not copy the status if the mutant came from a different mutator', () => { @@ -658,7 +658,7 @@ describe(IncrementalDiffer.name, () => { describe('test changes', () => { it('should identify that a mutant state can be reused when no tests changed', () => { const actualDiff = new ScenarioBuilder().withMathProjectExample().withTestFile().act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it('should identify that mutant state can be reused with changes above', () => { @@ -670,7 +670,7 @@ describe(IncrementalDiffer.name, () => { .act(); // Assert - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it('should identify that mutant state can be reused with changes before', () => { @@ -680,7 +680,7 @@ describe(IncrementalDiffer.name, () => { .withLocatedTest() .withAddedTextBeforeTest('/*text-added*/') .act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it('should identify that mutant state can be reused with changes below', () => { @@ -690,7 +690,7 @@ describe(IncrementalDiffer.name, () => { .withLocatedTest({ includeEnd: true }) .withSecondTest({ located: true }) .act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it('should identify that mutant state can be reused with changes behind', () => { @@ -700,7 +700,7 @@ describe(IncrementalDiffer.name, () => { .withLocatedTest({ includeEnd: true }) .withAddedTextAfterTest('/*text-added*/') .act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it('should not reuse a mutant state when a covering test gets code added', () => { @@ -723,7 +723,7 @@ describe(IncrementalDiffer.name, () => { .withSecondTest({ located: true }) .withSecondTestInIncrementalReport() .act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it('should close locations for tests on the same location in the incremental report', () => { @@ -733,45 +733,39 @@ describe(IncrementalDiffer.name, () => { .withUpdatedTestGenerationAndAdditionalTest() .withTestGenerationAndAdditionalTestIncrementalReport() .act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); // See #3909 it('should close locations for tests on the same location in the incremental report when they are the last tests', () => { // Test cases can generate tests, make sure the correct end position is chosen in those cases const actualDiff = new ScenarioBuilder().withMathProjectExample().withTestGeneration().withTestGenerationIncrementalReport().act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it('should identify that a non-"Killed" state can be reused when a test is removed', () => { - const actualDiff = new ScenarioBuilder() - .withMathProjectExample({ mutantState: MutantStatus.Survived }) - .withSecondTestInIncrementalReport() - .act(); - expect(actualDiff[0].status).eq(MutantStatus.Survived); + const actualDiff = new ScenarioBuilder().withMathProjectExample({ mutantState: 'Survived' }).withSecondTestInIncrementalReport().act(); + expect(actualDiff[0].status).eq('Survived'); }); it('should identify that a non-"Killed" state cannot be reused when a test is added', () => { - const actualDiff = new ScenarioBuilder() - .withMathProjectExample({ mutantState: MutantStatus.Survived }) - .withSecondTest({ located: false }) - .act(); + const actualDiff = new ScenarioBuilder().withMathProjectExample({ mutantState: 'Survived' }).withSecondTest({ located: false }).act(); expect(actualDiff[0].status).undefined; }); it('should identify that a "Killed" state can be reused when the killing test didn\'t change', () => { const actualDiff = new ScenarioBuilder() - .withMathProjectExample({ mutantState: MutantStatus.Killed }) + .withMathProjectExample({ mutantState: 'Killed' }) .withTestFile() .withLocatedTest() .withSecondTestInIncrementalReport() .act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + expect(actualDiff[0].status).eq('Killed'); }); it('should identify that a "Killed" state cannot be reused when the killing test was removed', () => { const actualDiff = new ScenarioBuilder() - .withMathProjectExample({ mutantState: MutantStatus.Killed }) + .withMathProjectExample({ mutantState: 'Killed' }) .withTestFile() .withSecondTestInIncrementalReport({ isKillingTest: true }) .act(); @@ -779,8 +773,8 @@ describe(IncrementalDiffer.name, () => { }); it('should identify that a "Killed" state for a static mutant (no covering tests) can be reused when the killing test didn\'t change', () => { - const actualDiff = new ScenarioBuilder().withMathProjectExample({ mutantState: MutantStatus.Killed, isStatic: true }).act(); - expect(actualDiff[0].status).eq(MutantStatus.Killed); + const actualDiff = new ScenarioBuilder().withMathProjectExample({ mutantState: 'Killed', isStatic: true }).act(); + expect(actualDiff[0].status).eq('Killed'); }); it('should collect an added test', () => { @@ -830,7 +824,7 @@ describe(IncrementalDiffer.name, () => { expect(mutants).lengthOf(2); const [, actualMutant] = mutants; expect(actualMutant.id).includes('src/multiply.js@1:11-1:12'); - expect(actualMutant.status).eq(MutantStatus.Killed); + expect(actualMutant.status).eq('Killed'); expect(actualMutant.fileName).eq(path.resolve(srcMultiply)); }); it("should keep historic tests that didn't run this time around", () => { diff --git a/packages/core/test/unit/mutants/mutant-test-planner.spec.ts b/packages/core/test/unit/mutants/mutant-test-planner.spec.ts index 993be7ec48..4059f485d7 100644 --- a/packages/core/test/unit/mutants/mutant-test-planner.spec.ts +++ b/packages/core/test/unit/mutants/mutant-test-planner.spec.ts @@ -3,7 +3,7 @@ import path from 'path'; import sinon from 'sinon'; import { expect } from 'chai'; import { factory, testInjector } from '@stryker-mutator/test-helpers'; -import { MutantEarlyResultPlan, MutantRunPlan, MutantTestPlan, PlanKind, Mutant, MutantStatus, schema } from '@stryker-mutator/api/core'; +import { MutantEarlyResultPlan, MutantRunPlan, MutantTestPlan, PlanKind, Mutant, schema } from '@stryker-mutator/api/core'; import { Reporter } from '@stryker-mutator/api/report'; import { MutantTestPlanner } from '../../../src/mutants/index.js'; @@ -48,14 +48,14 @@ describe(MutantTestPlanner.name, () => { } it('should make an early result plan for an ignored mutant', async () => { - const mutant = factory.mutant({ id: '2', status: MutantStatus.Ignored, statusReason: 'foo should ignore' }); + const mutant = factory.mutant({ id: '2', status: 'Ignored', statusReason: 'foo should ignore' }); // Act const result = await act([mutant]); // Assert const expected: MutantEarlyResultPlan[] = [ - { plan: PlanKind.EarlyResult, mutant: { ...mutant, static: false, status: MutantStatus.Ignored, coveredBy: undefined, killedBy: undefined } }, + { plan: PlanKind.EarlyResult, mutant: { ...mutant, static: false, status: 'Ignored', coveredBy: undefined, killedBy: undefined } }, ]; expect(result).deep.eq(expected); }); @@ -199,7 +199,7 @@ describe(MutantTestPlanner.name, () => { plan: PlanKind.EarlyResult, mutant: { ...mutant, - status: MutantStatus.Ignored, + status: 'Ignored', statusReason: 'Static mutant (and "ignoreStatic" was enabled)', static: true, coveredBy: [], @@ -548,7 +548,7 @@ describe(MutantTestPlanner.name, () => { source: 'foo', mutants: [ factory.mutantResult({ - status: MutantStatus.Killed, + status: 'Killed', replacement: '<=', mutatorName: 'fooMutator', location: loc(0, 0, 0, 1), @@ -588,7 +588,7 @@ describe(MutantTestPlanner.name, () => { // Assert assertIsEarlyResultPlan(actualPlan); - expect(actualPlan.mutant.status).eq(MutantStatus.Killed); + expect(actualPlan.mutant.status).eq('Killed'); expect(actualPlan.mutant.killedBy).deep.eq(['spec1']); }); @@ -601,7 +601,7 @@ describe(MutantTestPlanner.name, () => { // Assert assertIsEarlyResultPlan(actualPlan); - expect(actualPlan.mutant.status).eq(MutantStatus.Killed); + expect(actualPlan.mutant.status).eq('Killed'); expect(actualPlan.mutant.killedBy).deep.eq(['spec1']); }); }); diff --git a/packages/core/test/unit/process/4-mutation-test-executor.spec.ts b/packages/core/test/unit/process/4-mutation-test-executor.spec.ts index f10da6a51d..a3d481df4a 100644 --- a/packages/core/test/unit/process/4-mutation-test-executor.spec.ts +++ b/packages/core/test/unit/process/4-mutation-test-executor.spec.ts @@ -6,7 +6,7 @@ import { TestRunner, MutantRunOptions, MutantRunResult, MutantRunStatus, Complet import { CheckResult, CheckStatus } from '@stryker-mutator/api/check'; import { mergeMap } from 'rxjs/operators'; import { Observable } from 'rxjs'; -import { Mutant, MutantStatus, MutantTestCoverage, MutantEarlyResultPlan, MutantRunPlan, MutantTestPlan } from '@stryker-mutator/api/core'; +import { Mutant, MutantTestCoverage, MutantEarlyResultPlan, MutantRunPlan, MutantTestPlan } from '@stryker-mutator/api/core'; import { I, Task } from '@stryker-mutator/util'; import { MutationTestExecutor } from '../../../src/process/index.js'; @@ -21,7 +21,7 @@ import { CheckerFacade } from '../../../src/checker/checker-facade.js'; function ignoredEarlyResultPlan(overrides?: Partial): MutantEarlyResultPlan { return factory.mutantEarlyResultPlan({ - mutant: { ...factory.mutant(overrides), status: MutantStatus.Ignored }, + mutant: { ...factory.mutant(overrides), status: 'Ignored' }, }); } @@ -148,7 +148,7 @@ describe(MutationTestExecutor.name, () => { await sut.execute(); // Assert - sinon.assert.calledWithExactly(mutationTestReportHelperMock.reportMutantStatus, mutantTestPlans[0].mutant, MutantStatus.Ignored); + sinon.assert.calledWithExactly(mutationTestReportHelperMock.reportMutantStatus, mutantTestPlans[0].mutant, 'Ignored'); }); it('should report an uncovered mutant with `NoCoverage`', async () => { @@ -160,7 +160,7 @@ describe(MutationTestExecutor.name, () => { await sut.execute(); // Assert - expect(mutationTestReportHelperMock.reportMutantStatus).calledWithExactly(mutantTestPlans[0].mutant, MutantStatus.NoCoverage); + expect(mutationTestReportHelperMock.reportMutantStatus).calledWithExactly(mutantTestPlans[0].mutant, 'NoCoverage'); }); }); diff --git a/packages/core/test/unit/reporters/clear-text-reporter.spec.ts b/packages/core/test/unit/reporters/clear-text-reporter.spec.ts index bfde0c8a35..4e0e3ea9c6 100644 --- a/packages/core/test/unit/reporters/clear-text-reporter.spec.ts +++ b/packages/core/test/unit/reporters/clear-text-reporter.spec.ts @@ -1,6 +1,6 @@ import os from 'os'; -import { MutantStatus, schema } from '@stryker-mutator/api/core'; +import { schema } from '@stryker-mutator/api/core'; import { testInjector, factory } from '@stryker-mutator/test-helpers'; import { expect } from 'chai'; import sinon from 'sinon'; @@ -34,7 +34,7 @@ describe(ClearTextReporter.name, () => { location: { start: { line: 0, column: 0 }, end: { line: 0, column: 0 } }, mutatorName: 'Block', replacement: '{}', - status: MutantStatus.Killed, + status: 'Killed', }, ], source: 'console.log("hello world!")', @@ -70,7 +70,7 @@ describe(ClearTextReporter.name, () => { location: { start: { line: 0, column: 0 }, end: { line: 0, column: 0 } }, mutatorName: 'Block', replacement: '{}', - status: MutantStatus.Killed, + status: 'Killed', }, ], source: 'console.log("hello world!")', @@ -96,7 +96,7 @@ describe(ClearTextReporter.name, () => { location: { start: { line: 0, column: 0 }, end: { line: 0, column: 0 } }, mutatorName: 'Block', replacement: '{}', - status: MutantStatus.Killed, + status: 'Killed', }, ], source: 'console.log("hello world!")', @@ -122,7 +122,7 @@ describe(ClearTextReporter.name, () => { location: { start: { line: 0, column: 0 }, end: { line: 0, column: 0 } }, mutatorName: 'Block', replacement: '{}', - status: MutantStatus.Ignored, + status: 'Ignored', }, ], source: 'console.log("hello world!")', @@ -156,7 +156,7 @@ describe(ClearTextReporter.name, () => { location: { start: { line: 0, column: 0 }, end: { line: 0, column: 0 } }, mutatorName: 'Block', replacement: '{}', - status: MutantStatus.Ignored, + status: 'Ignored', }, ], source: 'console.log("hello world!")', @@ -169,7 +169,7 @@ describe(ClearTextReporter.name, () => { location: { start: { line: 0, column: 0 }, end: { line: 0, column: 0 } }, mutatorName: 'Block', replacement: '{}', - status: MutantStatus.Killed, + status: 'Killed', }, ], source: 'console.log("hello world!")', @@ -239,7 +239,7 @@ describe(ClearTextReporter.name, () => { }); }); it('should report a killed mutant to debug', async () => { - mutant.status = MutantStatus.Killed; + mutant.status = 'Killed'; mutant.killedBy = ['1']; act(report); expect(testInjector.logger.debug).calledWithMatch(sinon.match('[Killed] Math')); @@ -249,7 +249,7 @@ describe(ClearTextReporter.name, () => { }); it('should report a CompileError mutant to debug', async () => { - mutant.status = MutantStatus.CompileError; + mutant.status = 'CompileError'; mutant.statusReason = 'could not call bar of undefined'; act(report); expect(testInjector.logger.debug).calledWithMatch(sinon.match('[CompileError] Math')); @@ -259,7 +259,7 @@ describe(ClearTextReporter.name, () => { }); it('should report a NoCoverage mutant to stdout', async () => { - mutant.status = MutantStatus.NoCoverage; + mutant.status = 'NoCoverage'; act(report); expect(stdoutStub).calledWithMatch(sinon.match('[NoCoverage] Math')); expect(stdoutStub).calledWith(`${chalk.red('- foo')}${os.EOL}`); @@ -267,34 +267,34 @@ describe(ClearTextReporter.name, () => { }); it('should report a Survived mutant to stdout', async () => { - mutant.status = MutantStatus.Survived; + mutant.status = 'Survived'; act(report); expect(stdoutStub).calledWithMatch(sinon.match('[Survived] Math')); }); it('should not report a Survived mutant to stdout when reportMutants is not true', async () => { testInjector.options.clearTextReporter.reportMutants = false; - mutant.status = MutantStatus.Survived; + mutant.status = 'Survived'; act(report); expect(stdoutStub).not.calledWithMatch(sinon.match('[Survived] Math')); }); it('should not report a NoCoverage mutant to stdout when reportMutants is not true', async () => { testInjector.options.clearTextReporter.reportMutants = false; - mutant.status = MutantStatus.NoCoverage; + mutant.status = 'NoCoverage'; act(report); expect(stdoutStub).not.calledWithMatch(sinon.match('[NoCoverage] Math')); }); it('should report a Timeout mutant to stdout', async () => { - mutant.status = MutantStatus.Timeout; + mutant.status = 'Timeout'; act(report); expect(testInjector.logger.debug).calledWithMatch(sinon.match('[Timeout] Math')); }); it('should report the tests ran for a Survived mutant to stdout for "perTest" coverage analysis', async () => { mutant.coveredBy = ['1', '2', '3']; - mutant.status = MutantStatus.Survived; + mutant.status = 'Survived'; act(report); expect(stdoutStub).calledWithExactly(`Tests ran:${os.EOL}`); expect(stdoutStub).calledWithExactly(` foo should be bar${os.EOL}`); @@ -305,7 +305,7 @@ describe(ClearTextReporter.name, () => { it('should report the max tests to log and however many more tests', async () => { testInjector.options.clearTextReporter.maxTestsToLog = 2; mutant.coveredBy = ['1', '2', '3']; - mutant.status = MutantStatus.Survived; + mutant.status = 'Survived'; act(report); expect(stdoutStub).calledWithExactly(`Tests ran:${os.EOL}`); expect(stdoutStub).calledWithExactly(` foo should be bar${os.EOL}`); @@ -318,7 +318,7 @@ describe(ClearTextReporter.name, () => { it('should report that all tests have ran for a surviving mutant that is static', async () => { testInjector.options.clearTextReporter.maxTestsToLog = 2; mutant.static = true; - mutant.status = MutantStatus.Survived; + mutant.status = 'Survived'; act(report); expect(stdoutStub).calledWithExactly(`Ran all tests for this mutant.${os.EOL}`); }); @@ -326,7 +326,7 @@ describe(ClearTextReporter.name, () => { it('should not log individual ran tests when logTests is not true', () => { testInjector.options.clearTextReporter.logTests = false; mutant.coveredBy = ['1', '2', '3']; - mutant.status = MutantStatus.Survived; + mutant.status = 'Survived'; act(report); const allCalls = stdoutStub.getCalls().map((call) => call.args.join('')); @@ -345,7 +345,7 @@ describe(ClearTextReporter.name, () => { }); it('should log source file location', () => { - mutant.status = MutantStatus.Survived; + mutant.status = 'Survived'; mutant.location.start = { line: 4, column: 6 }; act(report); @@ -354,7 +354,7 @@ describe(ClearTextReporter.name, () => { it('should log source file names without colored text when clearTextReporter is not false and allowConsoleColors is false', () => { testInjector.options.allowConsoleColors = false; - mutant.status = MutantStatus.Survived; + mutant.status = 'Survived'; mutant.location.start = { line: 4, column: 6 }; // Recreate, color setting is set in constructor sut = testInjector.injector.injectClass(ClearTextReporter); diff --git a/packages/core/test/unit/reporters/dashboard-reporter/dashboard-reporter.spec.ts b/packages/core/test/unit/reporters/dashboard-reporter/dashboard-reporter.spec.ts index 8f287fcf73..e3b44abd0d 100644 --- a/packages/core/test/unit/reporters/dashboard-reporter/dashboard-reporter.spec.ts +++ b/packages/core/test/unit/reporters/dashboard-reporter/dashboard-reporter.spec.ts @@ -1,7 +1,7 @@ import { testInjector, factory } from '@stryker-mutator/test-helpers'; import { expect } from 'chai'; import sinon from 'sinon'; -import { MutantStatus, ReportType, schema } from '@stryker-mutator/api/core'; +import { ReportType, schema } from '@stryker-mutator/api/core'; import { calculateMutationTestMetrics } from 'mutation-testing-metrics'; @@ -79,10 +79,10 @@ describe(DashboardReporter.name, () => { files: { 'a.js': factory.mutationTestReportSchemaFileResult({ mutants: [ - factory.mutationTestReportSchemaMutantResult({ status: MutantStatus.Killed }), - factory.mutationTestReportSchemaMutantResult({ status: MutantStatus.Killed }), - factory.mutationTestReportSchemaMutantResult({ status: MutantStatus.Killed }), - factory.mutationTestReportSchemaMutantResult({ status: MutantStatus.Survived }), + factory.mutationTestReportSchemaMutantResult({ status: 'Killed' }), + factory.mutationTestReportSchemaMutantResult({ status: 'Killed' }), + factory.mutationTestReportSchemaMutantResult({ status: 'Killed' }), + factory.mutationTestReportSchemaMutantResult({ status: 'Survived' }), ], }), }, diff --git a/packages/core/test/unit/reporters/dots-reporter.spec.ts b/packages/core/test/unit/reporters/dots-reporter.spec.ts index 2d5592880b..2c97bde7d1 100644 --- a/packages/core/test/unit/reporters/dots-reporter.spec.ts +++ b/packages/core/test/unit/reporters/dots-reporter.spec.ts @@ -3,7 +3,6 @@ import os from 'os'; import { expect } from 'chai'; import sinon from 'sinon'; import chalk from 'chalk'; -import { MutantStatus } from '@stryker-mutator/api/core'; import { factory } from '@stryker-mutator/test-helpers'; import { DotsReporter } from '../../../src/reporters/dots-reporter.js'; @@ -30,7 +29,7 @@ describe(DotsReporter.name, () => { }); it('should log "S" when status is Survived', () => { - sut.onMutantTested(factory.mutantResult({ status: MutantStatus.Survived })); + sut.onMutantTested(factory.mutantResult({ status: 'Survived' })); expect(process.stdout.write).to.have.been.calledWith(chalk.bold.red('S')); }); }); diff --git a/packages/core/test/unit/reporters/mutation-test-report-helper.spec.ts b/packages/core/test/unit/reporters/mutation-test-report-helper.spec.ts index 655420c308..08be8a19a7 100644 --- a/packages/core/test/unit/reporters/mutation-test-report-helper.spec.ts +++ b/packages/core/test/unit/reporters/mutation-test-report-helper.spec.ts @@ -1,7 +1,7 @@ import path from 'path'; import sinon from 'sinon'; -import { Location, MutantResult, MutantStatus, schema } from '@stryker-mutator/api/core'; +import { Location, MutantResult, schema } from '@stryker-mutator/api/core'; import { Reporter } from '@stryker-mutator/api/report'; import { factory, testInjector } from '@stryker-mutator/test-helpers'; import type { requireResolve } from '@stryker-mutator/util'; @@ -76,7 +76,7 @@ describe(MutationTestReportHelper.name, () => { { mutatorName: 'Foo', fileName: 'foo.js', - status: MutantStatus.Killed, + status: 'Killed', location: { start: { line: 1, column: 2 }, end: { line: 4, column: 5 } }, replacement: '+', id: '1', @@ -189,15 +189,15 @@ describe(MutationTestReportHelper.name, () => { static: true, statusReason: 'smacked on the head', testsCompleted: 32, - status: MutantStatus.Killed, + status: 'Killed', }; const inputMutants = [ killedMutantResult, - factory.mutantResult({ fileName: 'bar.js', status: MutantStatus.NoCoverage }), - factory.mutantResult({ fileName: 'baz.js', status: MutantStatus.RuntimeError }), - factory.mutantResult({ fileName: 'qux.js', status: MutantStatus.Survived }), - factory.mutantResult({ fileName: '5.js', status: MutantStatus.Timeout }), - factory.mutantResult({ fileName: '6.js', status: MutantStatus.CompileError }), + factory.mutantResult({ fileName: 'bar.js', status: 'NoCoverage' }), + factory.mutantResult({ fileName: 'baz.js', status: 'RuntimeError' }), + factory.mutantResult({ fileName: 'qux.js', status: 'Survived' }), + factory.mutantResult({ fileName: '5.js', status: 'Timeout' }), + factory.mutantResult({ fileName: '6.js', status: 'CompileError' }), ]; inputMutants.forEach(({ fileName }) => { fileSystemTestDouble.files[fileName] = ''; @@ -216,15 +216,15 @@ describe(MutationTestReportHelper.name, () => { static: true, statusReason: 'smacked on the head', testsCompleted: 32, - status: MutantStatus.Killed, + status: 'Killed', }; expect(Object.keys(actualReport.files)).lengthOf(6); expect(actualReport.files['foo.js'].mutants[0]).include(expectedKilledMutant); - expect(actualReport.files['bar.js'].mutants[0]).include({ status: MutantStatus.NoCoverage }); - expect(actualReport.files['baz.js'].mutants[0]).include({ status: MutantStatus.RuntimeError }); - expect(actualReport.files['qux.js'].mutants[0]).include({ status: MutantStatus.Survived }); - expect(actualReport.files['5.js'].mutants[0]).include({ status: MutantStatus.Timeout }); - expect(actualReport.files['6.js'].mutants[0]).include({ status: MutantStatus.CompileError }); + expect(actualReport.files['bar.js'].mutants[0]).include({ status: 'NoCoverage' }); + expect(actualReport.files['baz.js'].mutants[0]).include({ status: 'RuntimeError' }); + expect(actualReport.files['qux.js'].mutants[0]).include({ status: 'Survived' }); + expect(actualReport.files['5.js'].mutants[0]).include({ status: 'Timeout' }); + expect(actualReport.files['6.js'].mutants[0]).include({ status: 'CompileError' }); }); it('should not offset the location when reporting all mutants', async () => { @@ -424,7 +424,7 @@ describe(MutationTestReportHelper.name, () => { }); it('should not set exit code = 1 if `threshold.break` is not configured', async () => { - await actReportAll([factory.mutantResult({ status: MutantStatus.Survived })]); + await actReportAll([factory.mutantResult({ status: 'Survived' })]); expect(setExitCodeStub).not.called; expect(testInjector.logger.debug).calledWith( @@ -434,14 +434,14 @@ describe(MutationTestReportHelper.name, () => { it('should not set exit code = 1 if `threshold.break` === score', async () => { testInjector.options.thresholds.break = 50; - await actReportAll([factory.mutantResult({ status: MutantStatus.Survived }), factory.mutantResult({ status: MutantStatus.Killed })]); // 50 % + await actReportAll([factory.mutantResult({ status: 'Survived' }), factory.mutantResult({ status: 'Killed' })]); // 50 % expect(setExitCodeStub).not.called; expect(testInjector.logger.info).calledWith('Final mutation score of 50.00 is greater than or equal to break threshold 50'); }); it('should set exit code = 1 if `threshold.break` > score', async () => { testInjector.options.thresholds.break = 50.01; - await actReportAll([factory.mutantResult({ status: MutantStatus.Survived }), factory.mutantResult({ status: MutantStatus.Killed })]); // 50 % + await actReportAll([factory.mutantResult({ status: 'Survived' }), factory.mutantResult({ status: 'Killed' })]); // 50 % expect(setExitCodeStub).calledWith(1); expect(testInjector.logger.error).calledWith('Final mutation score 50.00 under breaking threshold 50.01, setting exit code to 1 (failure).'); expect(testInjector.logger.info).calledWith('(improve mutation score or set `thresholds.break = null` to prevent this error in the future)'); @@ -501,7 +501,7 @@ describe(MutationTestReportHelper.name, () => { // Assert const expected: Partial = { - status: MutantStatus.CompileError, + status: 'CompileError', statusReason: 'cannot call foo of undefined', }; expect(actual).include(expected); @@ -523,11 +523,11 @@ describe(MutationTestReportHelper.name, () => { const sut = createSut(); // Act - const actual = sut.reportMutantStatus(input, MutantStatus.NoCoverage); + const actual = sut.reportMutantStatus(input, 'NoCoverage'); // Assert const expected: MutantResult = { - status: MutantStatus.NoCoverage, + status: 'NoCoverage', fileName: 'add.js', id: '3', location: { start: { column: 1, line: 1 }, end: { column: 1, line: 1 } }, @@ -553,7 +553,7 @@ describe(MutationTestReportHelper.name, () => { const sut = createSut(); // Act - sut.reportMutantStatus(input, MutantStatus.NoCoverage); + sut.reportMutantStatus(input, 'NoCoverage'); // Assert expect(input).to.not.deep.include({ start: { column: 1, line: 1 }, end: { column: 1, line: 1 } }); @@ -574,7 +574,7 @@ describe(MutationTestReportHelper.name, () => { // Assert const expected: Partial = { - status: MutantStatus.Killed, + status: 'Killed', killedBy: ['1'], testsCompleted: 42, statusReason: 'foo should have been bar at line 1', @@ -595,7 +595,7 @@ describe(MutationTestReportHelper.name, () => { // Assert const expected: Partial = { - status: MutantStatus.Killed, + status: 'Killed', killedBy: ['1', '2'], testsCompleted: 42, statusReason: 'foo should have been bar at line 1', @@ -615,7 +615,7 @@ describe(MutationTestReportHelper.name, () => { // Assert const expected: Partial = { - status: MutantStatus.RuntimeError, + status: 'RuntimeError', statusReason: 'Cannot call foo of null', }; expect(actual).deep.include(expected); @@ -630,7 +630,7 @@ describe(MutationTestReportHelper.name, () => { // Assert const expected: Partial = { - status: MutantStatus.Timeout, + status: 'Timeout', }; expect(actual).deep.include(expected); }); @@ -648,7 +648,7 @@ describe(MutationTestReportHelper.name, () => { // Assert const expected: Partial = { - status: MutantStatus.Survived, + status: 'Survived', coveredBy: ['1'], testsCompleted: 4, }; @@ -668,7 +668,7 @@ describe(MutationTestReportHelper.name, () => { // Assert const expected: Partial = { - status: MutantStatus.Survived, + status: 'Survived', coveredBy: undefined, }; expect(actual).deep.include(expected); diff --git a/packages/core/test/unit/reporters/progress-keeper.spec.ts b/packages/core/test/unit/reporters/progress-keeper.spec.ts index d7afff3bc8..0fe05b5a32 100644 --- a/packages/core/test/unit/reporters/progress-keeper.spec.ts +++ b/packages/core/test/unit/reporters/progress-keeper.spec.ts @@ -1,6 +1,5 @@ import { expect } from 'chai'; import { factory } from '@stryker-mutator/test-helpers'; -import { MutantStatus } from 'mutation-testing-report-schema'; import { DryRunCompletedEvent, MutationTestingPlanReadyEvent } from '@stryker-mutator/api/report'; @@ -33,7 +32,7 @@ describe(ProgressKeeper.name, () => { ); // Act - sut.onMutantTested(factory.mutantResult({ id: '1', status: MutantStatus.Survived })); + sut.onMutantTested(factory.mutantResult({ id: '1', status: 'Survived' })); // Assert expect(sut.progressForTesting.survived).eq(0); diff --git a/packages/instrumenter/src/mutant.ts b/packages/instrumenter/src/mutant.ts index b23d8e3f99..3decfd65dc 100644 --- a/packages/instrumenter/src/mutant.ts +++ b/packages/instrumenter/src/mutant.ts @@ -1,6 +1,6 @@ import babel, { type types } from '@babel/core'; import generate from '@babel/generator'; -import { Mutant as ApiMutant, Location, Position, MutantStatus } from '@stryker-mutator/api/core'; +import { Mutant as ApiMutant, Location, Position } from '@stryker-mutator/api/core'; import { deepCloneNode, eqNode } from './util/index.js'; @@ -41,7 +41,7 @@ export class Mutant implements Mutable { mutatorName: this.mutatorName, replacement: this.replacementCode, statusReason: this.ignoreReason, - status: this.ignoreReason ? MutantStatus.Ignored : undefined, + status: this.ignoreReason ? 'Ignored' : undefined, }; } diff --git a/packages/instrumenter/test/unit/mutant.spec.ts b/packages/instrumenter/test/unit/mutant.spec.ts index 744e67818d..56c330fc96 100644 --- a/packages/instrumenter/test/unit/mutant.spec.ts +++ b/packages/instrumenter/test/unit/mutant.spec.ts @@ -1,6 +1,6 @@ import babel from '@babel/core'; import generator from '@babel/generator'; -import { Mutant as MutantApi, MutantStatus } from '@stryker-mutator/api/core'; +import { Mutant as MutantApi } from '@stryker-mutator/api/core'; import { expect } from 'chai'; import { Mutant } from '../../src/mutant.js'; @@ -41,7 +41,7 @@ describe(Mutant.name, () => { mutatorName: 'fooMutator', replacement: '"Stryker was here!"', statusReason: 'ignore', - status: MutantStatus.Ignored, + status: 'Ignored', }; expect(mutant.toApiMutant()).deep.include(expected); }); diff --git a/packages/test-helpers/package.json b/packages/test-helpers/package.json index 0e33a369a6..386698d056 100644 --- a/packages/test-helpers/package.json +++ b/packages/test-helpers/package.json @@ -26,7 +26,7 @@ "dependencies": { "ajv": "~8.12.0", "flatted": "~3.2.5", - "mutation-testing-metrics": "2.0.5", + "mutation-testing-metrics": "3.0.0", "rxjs": "~7.8.0" }, "devDependencies": { diff --git a/packages/test-helpers/src/factory.ts b/packages/test-helpers/src/factory.ts index b4b785a5f4..089dabc23d 100644 --- a/packages/test-helpers/src/factory.ts +++ b/packages/test-helpers/src/factory.ts @@ -10,7 +10,6 @@ import { MutantResult, MutantCoverage, schema, - MutantStatus, MutantRunPlan, PlanKind, MutantEarlyResultPlan, @@ -79,17 +78,17 @@ export const warningOptions = factoryMethod(() => ({ })); export const killedMutantResult = (overrides?: Partial>): MutantResult => - mutantResult({ ...overrides, status: MutantStatus.Killed, killedBy: ['45'], testsCompleted: 2 }); + mutantResult({ ...overrides, status: 'Killed', killedBy: ['45'], testsCompleted: 2 }); export const survivedMutantResult = (overrides?: Partial>): MutantResult => - mutantResult({ ...overrides, status: MutantStatus.Survived, killedBy: ['45'], testsCompleted: 2 }); + mutantResult({ ...overrides, status: 'Survived', killedBy: ['45'], testsCompleted: 2 }); export const timeoutMutantResult = (overrides?: Partial>): MutantResult => - mutantResult({ ...overrides, status: MutantStatus.Timeout, statusReason: 'expected error' }); + mutantResult({ ...overrides, status: 'Timeout', statusReason: 'expected error' }); export const runtimeErrorMutantResult = (overrides?: Partial>): MutantResult => - mutantResult({ ...overrides, status: MutantStatus.RuntimeError, statusReason: 'expected error' }); + mutantResult({ ...overrides, status: 'RuntimeError', statusReason: 'expected error' }); export const ignoredMutantResult = (overrides?: Partial>): MutantResult => - mutantResult({ ...overrides, status: MutantStatus.Ignored, statusReason: 'Ignored by "fooMutator" in excludedMutations' }); + mutantResult({ ...overrides, status: 'Ignored', statusReason: 'Ignored by "fooMutator" in excludedMutations' }); export const noCoverageMutantResult = (overrides?: Partial>): MutantResult => - mutantResult({ ...overrides, status: MutantStatus.NoCoverage }); + mutantResult({ ...overrides, status: 'NoCoverage' }); export const mutantResult = factoryMethod(() => ({ id: '256', @@ -98,7 +97,7 @@ export const mutantResult = factoryMethod(() => ({ range: [0, 0], replacement: '', fileName: 'file.js', - status: MutantStatus.Survived, + status: 'Survived', coveredBy: ['1', '2'], testsCompleted: 2, static: false, @@ -113,7 +112,7 @@ export const mutationTestReportSchemaMutantResult = factoryMethod(() => ({ location: location(), })); -export const ignoredMutantTestCoverage = factoryMethod(() => ({ - status: MutantStatus.Ignored, +export const ignoredMutantTestCoverage = factoryMethod(() => ({ + status: 'Ignored', coveredBy: undefined, fileName: '', id: '1', @@ -362,7 +361,7 @@ export const mutantRunPlan = factoryMethod(() => ({ export const mutantEarlyResultPlan = factoryMethod(() => ({ plan: PlanKind.EarlyResult, - mutant: { ...mutantTestCoverage(), status: MutantStatus.Ignored }, + mutant: { ...mutantTestCoverage(), status: 'Ignored' }, })); export const mutationTestingPlanReadyEvent = factoryMethod(() => ({