Open FlinnBurgess opened 10 months ago
Hi @FlinnBurgess thanks for opening this issue. Sorry it took me a while to get around to it.
I assume you've read through https://stryker-mutator.io/docs/stryker-js/jest-runner/#coverage-analysis
As you can see from the stack trace we're requiring your jest environment from import-jest-environment.cts
directly. This means that we're using require(..)
on a typescript file ('./fix-jsdom-environment.ts'). Since no custom loaders are registered this failed. I didn't know a test environment file as typescript was possible.
There are 2 ways I can think of to fix this issue.
.js
file).ts-node
:
{
"$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"_comment": "This config was generated using 'stryker init'. Please take a look at: https://stryker-mutator.io/docs/stryker-js/configuration/ for more information.",
"packageManager": "npm",
"reporters": [
"html",
"clear-text",
"progress"
],
"testRunner": "jest",
+ "testRunnerNodeArgs": ["--require", "ts-node/register"],
"jest": {
"configFile": "./jest.config.mjs"
},
"checkers": ["typescript"],
"tsconfigFile": "tsconfig.json",
"testRunner_comment": "Take a look at (missing 'homepage' URL in package.json) for information about the jest plugin.",
"coverageAnalysis": "perTest"
}
Summary
I'm trying to run Stryker on our NextJS project. Our
jest.config.mjs
file has a customtestEnvironment
parameter which points to a file containingimport JSDOMEnvironment from 'jest-environment-jsdom';
When I run
npx jest
all the tests run without issue. When I runstryker run
however, I end up with errors:Stryker config
Test runner config
Stryker environment
Test runner environment
Your Environment
Add stryker.log
This over and over again: