aws / aws/universal-test-runner
jest-junit cannot be resolved when univeral-test-runner is installed globally
- Dominant language
- TypeScript
- Stars
- 31
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
## 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 ()
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 ()
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
Contributor guide
Research direction
Reproduce the issue with the global @aws/universal-test-runner installation using `run-tests jest` and `TEP_REPORT_FORMAT="default" run-tests jest`. Start at the @aws/universal-test-adapter-jest entry point and trace how the `jest-junit` reporter is resolved; done means the default report works with either a local or global installation as described in Expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- cli, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100