-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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]: "expect" package now imports @types/node causing web projects to break #14418
Comments
After discussing this further: Jest does actually run your web application in a Node.js runtime environment (using mocks like However, if a project's unit tests do NOT choose to import from |
Thanks for opening this issue. The problem was reported in #14139 (comment) and the fix is waiting to be merged (see #14385). |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
>= 29.6.0
Steps to reproduce
Try to compile a TypeScript web project with Jest tests and code like this:
Expected behavior
It should compile because the compiler provides this definition:
lib.dom.d.ts
Actual behavior
It fails to compile because
expect
now also brings in@types/node
which has this conflicting definition:globals.d.ts
The error:
Real world failing build:
microsoft/rushstack#3949
https://github.com/microsoft/rushstack/actions/runs/5873236375/job/15926196196?pr=3949
Additional context
This is a regression introduced by PR #14139
https://github.com/jestjs/jest/pull/14139/files#diff-1f480f1988b7f343469bb28b165fad08b4cadc37da379e655f2317d3c5f048b3
Why it's wrong: Jest itself is a Node.js application, but the TypeScript typings for Jest's test API should not assume that the unit tests are targeting Node.js runtime. For example if the unit tests are for a web application, then the
setTimeout()
declaration may be different from the Node.js environment.Environment
The text was updated successfully, but these errors were encountered: