Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Wrong line number at error stack of global setup when using typescript #4220

Open
fysntian opened this issue Oct 22, 2023 · 0 comments

Comments

@fysntian
Copy link

Version

29.7.0

Steps to reproduce

  1. Clone my repo at https://github.com/fysntian/jest-demo
  2. npm install
  3. npm test
  4. Got the error message for global setup:

Error: Jest: Got error running globalSetup - C:\Users\fysntian\Workspace\jest-demo\src\global-setup.ts, reason: bootstrap error
at bootstrap (C:\Users\fysntian\Workspace\jest-demo\src\bootstrap.ts:4:11)

  1. npx ts-node src/runner.ts
  2. Got the error message for general ts-node running:

Error: bootstrap error
at bootstrap (C:\Users\fysntian\Workspace\jest-demo\src\bootstrap.ts:2:9)

  1. Comment "throw new Error('bootstrap error');" at src/bootstrap.ts@2

  2. npm test

  3. Get the test failure with stack:

    foo error

    1 | async function foo() {

    2 | throw new Error('foo error');
    | ^
    3 | }
    4 |
    5 | export default foo;

    at foo (src/app.ts:2:9)
    at Object. (src/app.test.ts:5:14)

Expected behavior

On 4: the stack of error says "bootstrap.ts:4", should be "bootstrap.ts:2" like the one on 6.
(On 9: the stack of error has the right line number.)

Actual behavior

The line number of error stack from a typescript global setup is wrong, and it seems because no inline source map, the line number is from the js compiled from ts.

Debug log

{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"29.1.1"},"message":"creating jest presets not handling JavaScript files","sequence":1,"time":"2023-10-22T12:54:57.768Z"}
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"29.1.1"},"message":"creating jest presets not handling JavaScript files","sequence":2,"time":"2023-10-22T12:54:57.774Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"29.1.1"},"message":"creating Importer singleton","sequence":3,"time":"2023-10-22T12:54:58.172Z"}

Additional context

No response

Environment

System:
    OS: Windows 10 10.0.22621
    CPU: (32) x64 13th Gen Intel(R) Core(TM) i9-13900K
  Binaries:
    Node: 16.18.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.6.6 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    jest: ^29.7.0 => 29.7.0
@fysntian fysntian changed the title [Bug]: [Bug]: Wrong line number at error stack of global setup when using typescript Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant