universal-test-runner
universal-test-runner copied to clipboard
jest-junit cannot be resolved when univeral-test-runner is installed globally
Describe the bug
Even though jest-junit is installed as a dependency of the jest adapter, it can't be resolved when used to generate default jest reports when universal-test-runner is installed globally.
Steps to reproduce
$ npm i -g @aws/universal-test-runner
$ mkdir test
$ cd test
$ npm init -y
$ npm i --save-dev jest
$ run-tests jest # works fine
$ TEP_REPORT_FORMAT="default" run-tests jest # fails
[WARN] [universal-test-runner]: Protocol version not specified! Defaulting to 0.1.0
[INFO] [universal-test-runner]: Found TEP_REPORT_FORMAT in environment, reading value
[INFO] [universal-test-runner]: Using Test Execution Protocol version 0.1.0
[INFO] [universal-test-runner]: Loaded adapter from @aws/universal-test-adapter-jest
[INFO] [universal-test-runner]: Calling executeTests on adapter...
[INFO] [universal-test-adapter-jest]: Running tests with jest using command: node_modules/.bin/jest --reporters jest-junit --reporters default
Error: Could not resolve a module for a custom reporter.
Module name: jest-junit
at /Users/msrose/jest/node_modules/jest-config/build/normalize.js:426:15
at Array.map (<anonymous>)
at normalizeReporters (/Users/msrose/jest/node_modules/jest-config/build/normalize.js:409:20)
at /Users/msrose/jest/node_modules/jest-config/build/normalize.js:747:17
at Array.reduce (<anonymous>)
at normalize (/Users/msrose/jest/node_modules/jest-config/build/normalize.js:608:14)
at readConfig (/Users/msrose/jest/node_modules/jest-config/build/index.js:160:74)
at async readConfigs (/Users/msrose/jest/node_modules/jest-config/build/index.js:421:26)
at async runCLI (/Users/msrose/jest/node_modules/@jest/core/build/cli/index.js:152:59)
at async Object.run (/Users/msrose/jest/node_modules/jest-cli/build/run.js:124:37)
[INFO] [universal-test-runner]: Finished executing tests.
[ERROR] [universal-test-runner]: Test run failed with exit code 1
Expected behavior
The jest adapter should use a locally-installed jest-junit if it exists, but succeed if it doesn't and use the globally installed one instead.
Version information
- OS: macOS Monterey 12.6.2
- Node.js version: 18.14.2
- CLI version (
npm ls @aws/universal-test-runner
): 0.2.0
Additional context
N/A