-
Notifications
You must be signed in to change notification settings - Fork 308
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]: Tests fail with ReferenceError: document is not defined
on Angular 19
#2883
Comments
ReferenceError: document is not defined
on Angular 19
I also have this issue on Angular 17 (it has been driving me crazy for the past four hours or so)! Angular version: 17.3.3
setup-jest.ts:
jest.config.ts:
Also fails with following jest.config.ts:
tsconfig.spec.json:
|
Same problem |
Guys and gals, as indicated by error stack it is probably caused by latest version (2.2.14) of nwsapi: See open issue at their repo: dperini/nwsapi#135 |
Yep, my tests run by downgrading to 2.2.13: |
Thank you so much, I was losing my mind😅 Is this somehting which will be fixed in the next release of |
@tomastrajan Anyhow, it is issues like these that kind of prove the whole entangledness/brittleness of the npm ecosystem. An undefined variable crashes a ton of seemingly or even totally unrelated applications. |
@dm-gc right, yeah it's unfortunate. Hmm, I was more thinking in a direction that the but actually it's even worse lol so it's fully on the jest side 🤦 |
Version
14.4.1
Steps to reproduce
ts-node
to use a TS file for Jest confignpm run test
Expected behavior
The tests pass
Actual behavior
The tests fail, with the following error:
Additional context
A reproduction example is here. Note that I created it by upgrading from Angular v18 to v19, but the setup and bug remain the same as in a newly created Angular v19 app.
Environment
The text was updated successfully, but these errors were encountered: