The main documented way to use jest-junit in CI is
jest --ci --reporters=default --reporters=jest-junit
The Jest documentation adds double quotes:
jest --reporters="default" --reporters="jest-junit"
However, in either case I get this error:
nps is executing `test.ci` : jest --ci --reporters=default --reporters=jest-junit **/*.test.[jt]s
Error: Could not resolve a module for a custom reporter.
Module name: tests/fail.test.ts
at <project_root>/node_modules/jest-config/build/normalize.js:426:15
at Array.map (<anonymous>)
at normalizeReporters (<project_root>/node_modules/jest-config/build/normalize.js:409:20)
at <project_root>/node_modules/jest-config/build/normalize.js:747:17
at Array.reduce (<anonymous>)
at normalize (<project_root>/node_modules/jest-config/build/normalize.js:608:14)
at readConfig (<project_root>/node_modules/jest-config/build/index.js:160:74)
at async readConfigs (<project_root>/node_modules/jest-config/build/index.js:424:26)
at async runCLI (<project_root>/node_modules/@jest/core/build/cli/index.js:151:59)
at async Object.run (<project_root>/node_modules/jest-cli/build/run.js:130:37)
It seems to be here in the jest-config
source.
The deprecated
jest --ci --testResultsProcessor=jest-junit
does work, but I'd prefer to avoid it given
The support for testResultsProcessor is only kept for legacy reasons and might be removed in the future. You should therefore prefer to configure jest-junit as a reporter.
What can be the problem with the reporter usage?
Jest version is 29.7.0, and I've checked that there's no mismatch between jest-config
, jest-cli
, and jest
. jest-junit
is 16.0.0.
In package.json
I have:
"jest": {
"clearMocks": true,
"collectCoverageFrom": [
"tests/**/*.{js,jsx,ts,tsx}"
],
"coverageReporters": [
"lcov"
],
"resetModules": true,
"resetMocks": true,
"setupFiles": [
"./tests/helper.ts"
],
"testEnvironment": "node",
"transform": {
"^.+\\.[jt]sx?$": "babel-jest"
}
},
There's no jest.config.*
file.
The main documented way to use jest-junit in CI is
jest --ci --reporters=default --reporters=jest-junit
The Jest documentation adds double quotes:
jest --reporters="default" --reporters="jest-junit"
However, in either case I get this error:
nps is executing `test.ci` : jest --ci --reporters=default --reporters=jest-junit **/*.test.[jt]s
Error: Could not resolve a module for a custom reporter.
Module name: tests/fail.test.ts
at <project_root>/node_modules/jest-config/build/normalize.js:426:15
at Array.map (<anonymous>)
at normalizeReporters (<project_root>/node_modules/jest-config/build/normalize.js:409:20)
at <project_root>/node_modules/jest-config/build/normalize.js:747:17
at Array.reduce (<anonymous>)
at normalize (<project_root>/node_modules/jest-config/build/normalize.js:608:14)
at readConfig (<project_root>/node_modules/jest-config/build/index.js:160:74)
at async readConfigs (<project_root>/node_modules/jest-config/build/index.js:424:26)
at async runCLI (<project_root>/node_modules/@jest/core/build/cli/index.js:151:59)
at async Object.run (<project_root>/node_modules/jest-cli/build/run.js:130:37)
It seems to be here in the jest-config
source.
The deprecated
jest --ci --testResultsProcessor=jest-junit
does work, but I'd prefer to avoid it given
The support for testResultsProcessor is only kept for legacy reasons and might be removed in the future. You should therefore prefer to configure jest-junit as a reporter.
What can be the problem with the reporter usage?
Jest version is 29.7.0, and I've checked that there's no mismatch between jest-config
, jest-cli
, and jest
. jest-junit
is 16.0.0.
In package.json
I have:
"jest": {
"clearMocks": true,
"collectCoverageFrom": [
"tests/**/*.{js,jsx,ts,tsx}"
],
"coverageReporters": [
"lcov"
],
"resetModules": true,
"resetMocks": true,
"setupFiles": [
"./tests/helper.ts"
],
"testEnvironment": "node",
"transform": {
"^.+\\.[jt]sx?$": "babel-jest"
}
},
There's no jest.config.*
file.
1 Answer
Reset to default 0The answer was just that without reporters
,
jest --ci **/*.test.[jt]s
works fine. With them, I needed --
to separate the test file glob:
jest --ci --reporters=default --reporters=jest-junit -- **/*.test.[jt]s