-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
[Bug]: Module Import Stack Trace sometimes broken #13248
Copy link
Copy link
Closed
Description
Version
29.0.3
Steps to reproduce
- Clone this repo:
git clone https://github.com/smcenlly/jest-stack-trace-issue - Install dependencies
npm install - From the CLI, run tests:
npm run test - See error and stack trace initially reported:
FAIL ./a.spec.js
✕ should correctly report stack trace (8 ms)
● should correctly report stack trace
Cannot find module './my-missing-import' from 'a.spec.js'
1 | it('should correctly report stack trace', () => {
> 2 | require('./my-missing-import');
| ^
3 | });
at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:487:11)
at Object.require (a.spec.js:2:3)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 0.205 s, estimated 1 s
Ran all test suites.
Watch Usage: Press w to show more.
- Add spaces at the end of line 2 (the missing import), eventually (after adding a number of spaces) the missing import is no longer reported correctly and will display as shown below:
FAIL ./a.spec.js
✕ should correctly report stack trace (1 ms)
● should correctly report stack trace
Cannot find module './my-missing-import' from 'a.spec.js'
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 0.136 s, estimated 1 s
Ran all test suites.
Watch Usage: Press w to show more.
Expected behavior
Described in steps to reproduce.
Actual behavior
Described in steps to reproduce.
Additional context
We have some automated integration tests as a part of our product (https://wallabjs.com) that test stack trace mapping for jest and identified this regression in the latest version of jest. I believe it is a result of @connectdotz commit: dbda13f.
Environment
System:
OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
Binaries:
Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.1/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
npmPackages:
jest: ^29.0.3 => 29.0.3and
System:
OS: macOS 12.5.1
CPU: (8) arm64 Apple M1
Binaries:
Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.1/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
npmPackages:
jest: ^29.0.3 => 29.0.3
Reactions are currently unavailable