PageSourceSearch

https://stryker-mutator.io/assets/js/9cd2921f.da903a8b.js

js stryker-mutator.io collected 2026-09-24 17:54:10 UTC 30,913 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkstryker_mutator_github_io=self.webpackChunkstryker_mutator_github_io||[]).push([["4570"],{84533:function(e,t,n){n.r(t),n.d(t,{metadata:function(){return r},default:function(){return u},frontMatter:function(){return o},contentTitle:function(){return l},toc:function(){return c},assets:function(){return a}});var r=JSON.parse('{"id":"stryker-js/troubleshooting","title":"Troubleshooting","description":"Below you\'ll find an ever-growing list of issues that you might occur when running StrykerJS on your project for the first time.","source":"@site/docs/stryker-js/troubleshooting.md","sourceDirName":"stryker-js","slug":"/stryker-js/troubleshooting","permalink":"/docs/stryker-js/troubleshooting","draft":false,"unlisted":false,"editUrl":"https://github.com/stryker-mutator/stryker-js/edit/master/docs/troubleshooting.md","tags":[],"version":"current","frontMatter":{"title":"Troubleshooting","custom_edit_url":"https://github.com/stryker-mutator/stryker-js/edit/master/docs/troubleshooting.md"},"sidebar":"docs","previous":{"title":"TypeScript Checker","permalink":"/docs/stryker-js/typescript-checker"},"next":{"title":"Angular","permalink":"/docs/stryker-js/guides/angular"}}'),s=n(91987),i=n(67008);let o={title:"Troubleshooting",custom_edit_url:"https://github.com/stryker-mutator/stryker-js/edit/master/docs/troubleshooting.md"},l,a={},c=[{value:"Build command fails",id:"build-command-fails",level:3},{value:"Initial test run fails",id:"initial-test-run-fails",level:3},{value:"No tests executed - Jest runner",id:"no-tests-executed---jest-runner",level:3},{value:"All mutants survive - Jest runner",id:"all-mutants-survive---jest-runner",level:3},{value:"Jest crashes with a multi project configuration",id:"jest-crashes-with-a-multi-project-configuration",level:3},{value:"Stryker generates mutants that survive, but are not compiled by TypeScript",id:"stryker-generates-mutants-that-survive-but-are-not-compiled-by-typescript",level:3},{value:"Error when running StrykerJS: <code>Committing semi space failed. Allocation failed - JavaScript heap out of memory</code>",id:"error-when-running-strykerjs-committing-semi-space-failed-allocation-failed---javascript-heap-out-of-memory",level:3},{value:"Mutating fails: Cannot use the decorators and decorators-legacy plugin together",id:"mutating-fails-cannot-use-the-decorators-and-decorators-legacy-plugin-together",level:3},{value:"Mutants survive but should be killed - Jest runner",id:"mutants-survive-but-should-be-killed---jest-runner",level:3},{value:"Error when running Stryker with the TypeScript checker: no watcher is registered.",id:"error-when-running-stryker-with-the-typescript-checker-no-watcher-is-registered",level:3},{value:"Plugins can&#39;t be found when using pnpm as package manager",id:"plugins-cant-be-found-when-using-pnpm-as-package-manager",level:3},{value:"All mutants survive - module-alias",id:"all-mutants-survive---module-alias",level:3},{value:"Vitest failed to find test files related to mutated files",id:"vitest-failed-to-find-test-files-related-to-mutated-files",level:3}];function d(e){let t={a:"a",blockquote:"blockquote",code:"code",em:"em",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.p,{children:"Below you'll find an ever-growing list of issues that you might occur when running StrykerJS on your project for the first time."}),"\n",(0,s.jsx)(t.h3,{id:"build-command-fails",children:"Build command fails"}),"\n",(0,s.jsx)(t.p,{children:"Example:"}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:" ERROR Stryker Unexpected error occurred while running Stryker Error: Command failed with exit code 1:\n my-build-command\n"})}),"\n"]}),"\n",(0,s.jsxs)(t.p,{children:["If you're running into issues with your ",(0,s.jsx)(t.code,{children:"buildCommand"}),", try to execute it by hand to make sure it works. For example, if your ",(0,s.jsx)(t.code,{children:"buildCommand"})," is ",(0,s.jsx)(t.code,{children:'"tsc -b path/to/tsconfig.json"'}),", try to run ",(0,s.jsx)(t.code,{children:"npx tsc  -b path/to/tsconfig.json"})," yourself, did it have the desired effect?"]}),"\n",(0,s.jsxs)(t.p,{children:["If that works, the next step would be to try the command yourself ",(0,s.jsx)(t.em,{children:"inside the Stryker sandbox directory"}),". Please ",(0,s.jsx)(t.code,{children:"cd"})," into the ",(0,s.jsx)(t.code,{children:".stryker-tmp/sandbox-xxxxx"})," directory and try the command there. For example:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-shell",children:"cd .stryker-tmp/sandbox-12345678\nnode ../../node_modules/typescript/bin/tsc -b path/to/tsconfig.json\n"})}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Note"}),": since the sandbox dir doesn't have you node_modules, you will need to specify the full path to the TypeScript compiler."]}),"\n",(0,s.jsx)(t.h3,{id:"initial-test-run-fails",children:"Initial test run fails"}),"\n",(0,s.jsx)(t.p,{children:"Example:"}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:"One or more tests resulted in an error\n[...] Cannot assign to 'stryNS_9fa48' because it is not a variable [...]\n"})}),"\n"]}),"\n",(0,s.jsxs)(t.p,{children:["The initial test run might fail when you're using ts-jest or tsx. The reason for this is that Stryker will mutate your co
1de and, by doing so, introduce type errors into your code. Stryker tries to ignore these errors by adding ",(0,s.jsx)(t.a,{href:"https://devblogs.microsoft.com/typescript/announcing-typescript-3-7/#ts-nocheck-in-typescript-files",children:(0,s.jsx)(t.code,{children:"// @ts-nocheck"})})," in your source files. However, this is only done for TypeScript-like files inside your ",(0,s.jsx)(t.code,{children:"lib"}),", ",(0,s.jsx)(t.code,{children:"src"}),", and ",(0,s.jsx)(t.code,{children:"test"})," directories by default. If you have your code somewhere else, you will need to override ",(0,s.jsx)(t.a,{href:"/docs/stryker-js/configuration#disabletypechecks-boolean--string",children:"disableTypeChecks"})," yourself:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-json",children:'{\n  "disableTypeChecks": "app/**/*.{js,ts,jsx,tsx,html,vue}"\n}\n'})}),"\n",(0,s.jsxs)(t.p,{children:["Another cause might be that you're using TypeScript lower then v3.7. In that case, you should update TypeScript to at least v3.7 or higher. Alternatively you can try to switch to another transpiler, like ",(0,s.jsx)(t.a,{href:"https://babeljs.io/docs/en/babel-preset-typescript",children:"babel"}),", but honestly, updating TypeScript should be your first choice."]}),"\n",(0,s.jsx)(t.h3,{id:"no-tests-executed---jest-runner",children:"No tests executed - Jest runner"}),"\n",(0,s.jsxs)(t.p,{children:["You might run into issues like this when using the ",(0,s.jsx)(t.code,{children:"@stryker-mutator/jest-runner"}),":"]}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:"No tests found, exiting with code 1\nRun with `--passWithNoTests` to exit with code 0\n"})}),"\n"]}),"\n",(0,s.jsxs)(t.p,{children:["This issue specifically occurs on Windows machines because Jest doesn't match hidden folders, and by default Stryker uses ",(0,s.jsx)(t.code,{children:".stryker-tmp"})," as the temporary directory name (which is hidden due to the leading dot)."]}),"\n",(0,s.jsxs)(t.p,{children:["You will need to override the ",(0,s.jsx)(t.code,{children:"tempDirName"})," to a directory without a ",(0,s.jsx)(t.code,{children:"."})," in front of it."]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-json",children:'{\n  "tempDirName": "stryker-tmp"\n}\n'})}),"\n",(0,s.jsxs)(t.p,{children:["See ",(0,s.jsx)(t.a,{href:"https://github.com/stryker-mutator/stryker-js/issues/1691",children:"#1691"})," for more info."]}),"\n",(0,s.jsx)(t.h3,{id:"all-mutants-survive---jest-runner",children:"All mutants survive - Jest runner"}),"\n",(0,s.jsxs)(t.p,{children:["When running with the ",(0,s.jsx)(t.code,{children:"@stryker-mutator/jest-runner"})," on windows you might run into the issue where all mutants survive unexpectedly:"]}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:"[...]\n#3. [Survived] ArithmeticOperator\nC:\\z\\github\\stryker-mutator\\stryker-js\\e2e\\test\\jest-node\\src\\sum.js:5:10\n-     return a - b;\n+     return a + b;\nRan all tests for this mutant.\n\nRan 0.00 tests per mutant on average.\n----------|---------|----------|-----------|------------|----------|---------|\nFile      | % score | # killed | # timeout | # survived | # no cov | # error |\n----------|---------|----------|-----------|------------|----------|---------|\nAll files |    0.00 |        0 |         0 |          4 |        0 |       0 |\n sum.js   |    0.00 |        0 |         0 |          4 |        0 |       0 |\n----------|---------|----------|-----------|------------|----------|---------|\n"})}),"\n"]}),"\n",(0,s.jsxs)(t.p,{children:["The root cause for this is that Jest doesn't support running in a hidden directory on windows, like StrykerJS does by default (the sandbox directory is located in ",(0,s.jsx)(t.code,{children:".stryker-tmp"}),", a hidden directory). See ",(0,s.jsx)(t.a,{href:"https://github.com/facebook/jest/issues/9728",children:"issue 9728"})," for more info."]}),"\n",(0,s.jsx)(t.p,{children:"Known workarounds:"}),"\n",(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsxs)(t.li,{children:["Change the ",(0,s.jsx)(t.a,{href:"/docs/stryker-js/configuration#tempdirname-string",children:(0,s.jsx)(t.code,{children:"tempDirName"})})," to a non-hidden directory, for example ",(0,s.jsx)(t.code,{children:"--tempDirName stryker
1-tmp"}),"."]}),"\n",(0,s.jsxs)(t.li,{children:["You can also choose to run Stryker in place, using ",(0,s.jsx)(t.a,{href:"/docs/stryker-js/configuration#inplace-boolean",children:(0,s.jsx)(t.code,{children:"--inPlace"})})]}),"\n"]}),"\n",(0,s.jsx)(t.h3,{id:"jest-crashes-with-a-multi-project-configuration",children:"Jest crashes with a multi project configuration"}),"\n",(0,s.jsx)(t.p,{children:"Example:"}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:" ERROR DryRunExecutor One or more tests resulted in an error:\n        Test runner crashed. Tried twice to restart it without any luck. Last time the error message was:\nError: Jest: Cannot use configuration as an object without a file path.\n    at readConfig (C:\\z\\github\\jest-issue\\node_modules\\jest-config\\build\\index.js:188:13)\n"})}),"\n"]}),"\n",(0,s.jsxs)(t.p,{children:["This can happen when you have multiple ",(0,s.jsx)(t.a,{href:"https://jestjs.io/docs/configuration#projects-arraystring--projectconfig",children:(0,s.jsx)(t.code,{children:'"projects"'})})," defined in your Jest configuration. Currently, the jest-runner uses the ",(0,s.jsx)(t.code,{children:"runCli"})," of Jest, which doesn't support this. However, ",(0,s.jsx)(t.a,{href:"https://github.com/facebook/jest/pull/11307",children:"the PR that adds support for this just merged"}),", so future releases of Jest should work."]}),"\n",(0,s.jsx)(t.p,{children:'Until then, the only known workaround is to configure Jest without using "projects" \u{1F937}\u200D\u2642\uFE0F.'}),"\n",(0,s.jsx)(t.h3,{id:"stryker-generates-mutants-that-survive-but-are-not-compiled-by-typescript",children:"Stryker generates mutants that survive, but are not compiled by TypeScript"}),"\n",(0,s.jsx)(t.p,{children:"If you are using TypeScript, it may happen that StrykerJS generates a mutant that survives, but is not compilable by TypeScript."}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Example"}),":"]}),"\n",(0,s.jsx)(t.p,{children:"In your production TS code, you have the following statement:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"let typesWithLabelsObjects: ComponentData[] = new Array<ComponentData>();\n"})}),"\n",(0,s.jsxs)(t.p,{children:["and one of the mutants generated by StrykerJS is the following ",(0,s.jsx)(t.code,{children:"ArrayMutation"})," one:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"let typesWithLabelsObjects: ComponentData[] = new Array([]);\n"})}),"\n",(0,s.jsx)(t.p,{children:"However, if you try to introduce such a change to your TypeScript code manually, the TypeScript's compiler will not compile this. In our example, you'd get the following compilation error:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:"Type 'any[][]' is not assignable to type 'ComponentData[]'.\n  Type 'any[]' is missing the following properties from type 'ComponentData': type, labelts(2322)\n"})}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Solution"}),":"]}),"\n",(0,s.jsxs)(t.p,{children:["To solve that, you need to add a ",(0,s.jsx)(t.a,{href:"/docs/stryker-js/typescript-checker#configuring",children:"typescript-checker plugin"})," to StrykerJS. Install it with ",(0,s.jsx)(t.code,{children:"npm install --save-dev @stryker-mutator/typescript-checker"})," and then add the following options to your stryker's config file:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:'{\n  "checkers": ["typescript"],\n  "tsconfigFile": "tsconfig.json"\n}\n'})}),"\n",(0,s.jsxs)(t.p,{children:["After adding this and running ",(0,s.jsx)(t.code,{children:"npx stryker run"})," you may get errors similar to this one:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:"node_modules/@types/react/index.d.ts:3075:13 - error TS2717: Subsequent property declarations must have the same type.  Property 'rt' must be of type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>', but here has type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>'.\n"})}),"\n",(0,s.jsxs)(t.p,{children:["If that happens, add ",(0,s.jsx)(t.code,{children:'"skipLibCheck": true'})," to your ",(0,s.jsx)(t.code,{children:"tsconfig"})," file.\n",(0,s.jsx)(t.strong,{children:"Note"}),": adding ",(0,s.jsx)(t.code,{children:"typescript-checker"})," to StrykerJS makes types safety better and you get less false negative results, but it comes with a performance cost. Mutating may take more time with the checker plugin."]}),"\n",(0,s.jsxs)(t.h3,{id:"error-when-running-strykerjs-committing-semi-space-failed-allocation-failed---javascript-heap-out-of-memory",children:["Error when running StrykerJS: ",(0,s.jsx)(t.code,{children:"Committing semi space failed. Allocation failed - JavaScript heap out of memory"})]}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Example"}),":"]}),"\n",(0,s.jsx)(t.p,{children:"When running Stryker mutations, you may get an error similar to the following one:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:"16:58:25 (17452) INFO ConfigReader Using stryker.config.json\n16:58:26 (17452) INFO InputFileResolver Found 2 of 2557 file(s) to be mutated.\n16:58:27 (17452) INFO Instrumenter Instrumented 2 source file(s) with 118 mutant(s)\n16:58:28 (17452) INFO ConcurrencyTokenProvider Creating 6 checker process(es) and 5 test runner process(es).\n16:59:40 (17452) INFO DryRunExecutor Starting initial test run. This may take a while.\n16:59:53 (17452) INFO DryRunExecutor Initial test run succeeded. Ran 72 tests in 13 seconds (net 250 ms, overhead 129
110 ms).\nMutation testing  [  ] 12% (elapsed: ~1m, remaining: ~7m) 15/118 tested (0 survived, 10 timed out)\n<--- Last few GCs ---\x3e\n[17452:0000022998429D50]    75135 ms: Scavenge 302.2 (313.0) -> 295.2 (313.0) MB, 0.8 / 0.2 ms  (average mu = 0.992, current mu = 0.975) task\n[17452:0000022998429D50]   125511 ms: Scavenge 302.0 (313.0) -> 295.9 (313.2) MB, 1.3 / 0.0 ms  (average mu = 0.992, current mu = 0.975) task\n[17452:0000022998429D50]   149148 ms: Scavenge 296.5 (301.2) -> 296.0 (301.7) MB, 2.3 / 0.2 ms  (average mu = 0.992, current mu = 0.975) allocation failure\n<--- JS stacktrace ---\x3e\nFATAL ERROR: Committing semi space failed. Allocation failed - JavaScript heap out of memory\n 1: 00007FF61D741DDF napi_wrap+109135\n 2: 00007FF61D6E6D06 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfElementsOffset+33350\n"})}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Solution"}),":"]}),"\n",(0,s.jsxs)(t.p,{children:["To solve that, you need to limit the number of workers. In the example about, 11 workers were created in total (6 checker processes and 5 test runner processes). In order to solve this issue, you may try to set ",(0,s.jsx)(t.code,{children:"--concurrency"})," setting in your stryker config. In case of the sample issue, adding ",(0,s.jsx)(t.code,{children:'"concurrency": 4'})," to ",(0,s.jsx)(t.code,{children:"stryker.config.json"})," solved the problem."]}),"\n",(0,s.jsx)(t.h3,{id:"mutating-fails-cannot-use-the-decorators-and-decorators-legacy-plugin-together",children:"Mutating fails: Cannot use the decorators and decorators-legacy plugin together"}),"\n",(0,s.jsx)(t.p,{children:"Example:"}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:"ERROR Stryker Unexpected error occurred while running Stryker Error: Cannot use the decorators and decorators-legacy plugin together\n   at validatePlugins (okay_all in src\\node_modules\\@babel\\parser\\lib\\index.js:10194:13)\n   at getParser (okay_all in src\\node_modules\\@babel\\parser\\lib\\index.js:14528:5)\n   at parse (okay_all in src\\node_modules\\@babel\\parser\\lib\\index.js:14511:12)\n   at parser (okay_all in src\\node_modules\\@babel\\core\\lib\\parser\\index.js:52:34)\n   at parser.next (<anonymous>)\n   at Object.parse (okay_all in src\\node_modules\\@babel\\core\\lib\\parse.js:31:37)\n   at parse.next (<anonymous>)\n   at step (okay_all in src\\node_modules\\gensync\\index.js:261:32)\n   at okay_all in src\\node_modules\\gensync\\index.js:273:13\n   at async.call.result.err.err (okay_all in src\\node_modules\\gensync\\index.js:223:11)\n"})}),"\n"]}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Solution"}),":"]}),"\n",(0,s.jsxs)(t.p,{children:["Stryker JS uses ",(0,s.jsx)(t.a,{href:"https://babeljs.io/docs/en/",children:"babel"})," to parse and mutate your files. It does so by reading the ",(0,s.jsx)(t.code,{children:".babelrc"})," and ",(0,s.jsx)(t.code,{children:"babel.config.js"})," files you have, but applies its own default plugins first. In rare circumstances, those default plugins are incompatible with your babel configuration."]}),"\n",(0,s.jsx)(t.p,{children:"Override the default babel plugins to solve this issue. For example, leaving it empty allows your own babel plugins to be used, without defaults from StrykerJS conflicting with it:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:'{\n  "mutator": {\n    "plugins": []\n  }\n}\n'})}),"\n",(0,s.jsxs)(t.p,{children:["Alternatively, you can start with the ",(0,s.jsx)(t.a,{href:"https://github.com/stryker-mutator/stryker-js/blob/0c98f98649cecd7e7222cc5f168afbe1071099e5/packages/instrumenter/src/parsers/js-parser.ts#L8-L32",children:"default list defined in StrykerJS"})," and start removing some of them until you get a working list."]}),"\n",(0,s.jsx)(t.h3,{id:"mutants-survive-but-should-be-killed---jest-runner",children:"Mutants survive but should be killed - Jest runner"}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Symptom"})}),"\n",(0,s.jsx)(t.p,{children:"For a TypeScript file the mutants don't get killed but a coverage (in Jest) is shown."}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Problem"})}),"\n",(0,s.jsxs)(t.p,{children:["The mutated source file is only implementing callbacks for a framework that uses express in the background as a 
1server. The unit tests for this module are written with Jest and are using Axios to make REST calls against the server. There is no module dependency needed for the test. But Stryker is using Jest's ",(0,s.jsx)(t.code,{children:"--findRelatedTests"})," to optimize the performance. And it looks like that this Jest feature is only looking at imports (see this ",(0,s.jsx)(t.a,{href:"https://stackoverflow.com/questions/44066996/how-does-jest-findrelatedtests-work-under-the-hood",children:"StackOverflow post"}),"."]}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Solution"})}),"\n",(0,s.jsx)(t.p,{children:"There are two solutions for this problem."}),"\n",(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsxs)(t.li,{children:["\n",(0,s.jsx)(t.p,{children:"Adding an (unused) import for the tested module get the mutants killed. This is not an optimal solution but it works."}),"\n",(0,s.jsx)(t.p,{children:"Example:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-typescript",children:"import {} from '../FileUnderTest';\n"})}),"\n"]}),"\n",(0,s.jsxs)(t.li,{children:["\n",(0,s.jsxs)(t.p,{children:["Deactivate the usage of this Jest feature by setting ",(0,s.jsx)(t.code,{children:"--findRelatedTests"})," to ",(0,s.jsx)(t.code,{children:"false"}),". See ",(0,s.jsx)(t.a,{href:"/docs/stryker-js/jest-runner#jestenablefindrelatedtests-boolean",children:"documentation"}),"."]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(t.h3,{id:"error-when-running-stryker-with-the-typescript-checker-no-watcher-is-registered",children:"Error when running Stryker with the TypeScript checker: no watcher is registered."}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Symptom"})}),"\n",(0,s.jsx)(t.p,{children:"When activating the TypeScript checker, you might run into this error:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:'22:23:36 (2804) ERROR Stryker Unexpected error occurred while running Stryker StrykerError:\nError: Tr
1ied to check file "app/app.component.ts" (which is part of your typescript project),\nbut no watcher is registered for it. Changes would go unnoticed. This probably means that you\nneed to expand the files that are included in your project.\n'})}),"\n",(0,s.jsx)(t.p,{children:"This error most often occurs in Angular projects, but can occur in any TS project."}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Problem"})}),"\n",(0,s.jsxs)(t.p,{children:["The problem here is that the TypeScript checker plugin uses the ",(0,s.jsx)(t.code,{children:"ts.createSolutionBuilderWithWatch"})," api. This is equivalent to you running ",(0,s.jsx)(t.code,{children:"tsc --build --watch"}),". This works great, but has one downside, files not explicitly included in your project's tsconfig.json file will not be watched. When files are not watched by the TypeScript compiler, the checker plugin cannot check for type errors for that mutant."]}),"\n",(0,s.jsx)(t.p,{children:"It has to choose to either let this mutant go unchecked or throw an error and stop running. Since you've configured the checker, you probably want the mutants to be checked, thus it makes sense to simply stop mutation testing so you can fix this issue."}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Solution"})}),"\n",(0,s.jsx)(t.p,{children:"The solution is to include all files that are mutated in your project's tsconfig.json file. If you have multiple tsconfig.json files, you probably need to change the one you've configured in your stryker.config.json. For example (for an angular project)"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-diff",children:'{\n  "extends": "./tsconfig.json",\n  "compilerOptions": {\n  "outDir": "./out-tsc/app",\n  "types": []\n-  "files": [\n-   "src/main.ts",\n-   "src/polyfills.ts"\n-  ],\n  "include": [\n-   "src/**/*.d.ts"\n+   "src/**/*.ts",\n+   "src/**/*.d.ts"\n  ],\n+ "exclude": [\n+   "src/**/*.spec.ts"\n+ ]\n}\n'})}),"\n",(0,s.jsx)(t.p,{children:"This shouldn't change anything about your Angular project. You're just being a bit more explicit in which files you want to include."}),"\n",(0,s.jsx)(t.h3,{id:"plugins-cant-be-found-when-using-pnpm-as-package-manager",children:"Plugins can't be found when using pnpm as package manager"}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Symptom"})}),"\n",(0,s.jsxs)(t.p,{children:["Stryker is unable to load plugins (like ",(0,s.jsx)(t.code,{children:"@stryker-mutator/typescript-checker"}),") when using pnpm as package manager.\nYou might run into errors like:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:'Cannot find TestRunner plugin "mocha". No TestRunner plugins were loaded.\n'})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Problem"})}),"\n",(0,s.jsxs)(t.p,{children:["When using npm or yarn as package manager, Stryker can automagically load plugins by scanning your ",(0,s.jsx)(t.code,{children:"node_modules"}),".\nBecause ",(0,s.jsx)(t.em,{children:"pnpm"})," uses a special directory structure to store dependencies, Stryker can't auto-detect plugins like the ",(0,s.jsx)(t.code,{children:"@stryker-mutator/typescript-checker"})," plugin."]}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Solution"})}),"\n",(0,s.jsx)(t.p,{children:"Explicitly specify the plugins to load in your Stryker configuration file."}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-diff",children:'{\n  "packageManager": "pnpm",\n  "testRunner": "jest",\n  "checkers": ["typescript"],\n+  "plugins": [\n+    "@stryker-mutator/jest-runner",\n+    "@stryker-mutator/typescript-checker"\n+  ]\n}\n'})}),"\n",(0,s.jsx)(t.h3,{id:"all-mutants-survive---module-alias",children:"All mutants survive - module-alias"}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Symptom"})}),"\n",(0,s.jsxs)(t.p,{children:["When using with the ",(0,s.jsx)(t.code,{children:"module-alias"})," you might run into the issue where all mutants survive unexpectedly:"]}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:"[...]\n#3. [Survived] ArithmeticOperator\nC:\\z\\github\\stryker-mutator\\stryker-js\\e2e\\test\\jest-node\\src\\sum.js:5:10\n-     return a - b;\n+     return a + b;\nRan all tests for this mutant.\n\nRan 0.00 tests per mutant on average.\n----------|---------|----------|-----------|------------|----------|---------|\nFile      | % score | # killed | # timeout | # survived | # no cov | # error |\n----------|---------|----------|-----------|------------|----------|---------|\nAll files |    0.00 |        0 |         0 |          4 |        0 |       0 |\n sum.js   |    0.00 |        0 |         0 |          4 |        0 |       0 |\n----------|---------|----------|-----------|------------|----------|---------|\n"})}),"\n"]}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Problem"})}),"\n",(0,s.jsxs)(t.p,{children:["The root cause is that StrykerJS's sandboxing does not support alias imports like ",(0,s.jsx)(t.code,{children:"module-alias/register"})," as it always imports from the local project instead of the sandbox used by Stryker."]}),"\n",(0,s.jsxs)(t.p,{children:["It is preferable to avoid using ",(0,s.jsx)(t.code,{children:"module-alias"})," for the following reasons:"]}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsx)(t.li,{children:"It works by overriding a private node API so it might break at any major node release."}),"\n",(0,s.jsx)(t.li,{children:"It will never work for native ESM."}),"\n"]}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Solution"})}),"\n",(0,s.jsxs)(t.p,{children:["To keep using ",(0,s.jsx)(t.code,{children:"module-alias"}),", there are 2 workarounds:"]}),"\n",(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsxs)(t.li,{children:["Mark the ",(0,s.jsx)(t.code,{children:"node_modules"})," folder as part of your sandbox:"]}),"\n"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-diff",children:'{\n+  "ignorePatterns": ["!node_modules"],\n+  "symlinkNodeModules": false\n}\n'})}),"\n",(0,s.jsxs)(t.ol,{start:"2",children:["\n",(0,s.jsxs)(t.li,{children:["Let StrykerJS mutate your files in place: ",(0,s.jsx)(t.code,{children:"npx stryker run --inPlace"})]}),"\n"]}),"\n",(0,s.jsx)(t.h3,{id:"vitest-failed-to-find-test-files-related-to-mutated-files",children:"Vitest failed to find test files related to mutated files"}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Symptom"})}),"\n",(0,s.jsxs)(t.p,{children:["When using the ",(0,s.jsx)(t.code,{children:"@stryker-mutator/vitest-runner"})," you might run into the issue where Vitest fails to find test files related to mutated files, failing the initial test run."]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:'INFO DryRunExecutor Starting initial test run (vitest test runner with "perTest" coverage analysis). This may take a while.\nWARN VitestTestRunner Vitest failed to find test files related to mutated files. Either disable `vitest.related` or import your source files directly from your test files. See https://stryker-mutator.io/docs/stryker-js/troubleshooting/#vitest-failed-to-find-test-files-related-to-mutated-files\nINFO DryRunExecutor No tests were found\nERROR Stryker No tests were executed. Stryker will exit prematurely. Please check your configuration.\n'})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Problem"})}),"\n",(0,s.jsxs)(t.p,{children:["Your test files don't import your source (mutated) f
1iles directly. For example, your test files call your production code via an API call (integration test) or some other indirect way. You can test this using ",(0,s.jsx)(t.code,{children:"npx vitest related source/my-file.ts"}),", that should also fail with the same error."]}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"Solution"})}),"\n",(0,s.jsx)(t.p,{children:"There are 2 possible solutions."}),"\n",(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsxs)(t.li,{children:["Disable ",(0,s.jsx)(t.code,{children:"related"})," in your stryker.config.json file.","\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-json",children:'{\n  "vitest": {\n    "related": false\n  }\n}\n'})}),"\n"]}),"\n",(0,s.jsxs)(t.li,{children:["Import your source files directly from your test files.","\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import '../src/file-under-test.ts';\n"})}),"\n"]}),"\n"]})]})}function u(e={}){let{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},67008:function(e,t,n){n.d(t,{R:function(){return o},x:function(){return l}});var r=n(71763);let s={},i=r.createContext(s);function o(e){let t=r.useContext(i);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),r.createElement(i.Provider,{value:t},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.