nwsapi: Last version is breaking my tests
ReferenceError: document is not defined
at …/…/node_modules/nwsapi/src/nwsapi.js:216:21
And it’s true, that line should use doc. or global.document, but document is really undefined.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 19
- Comments: 22 (6 by maintainers)
Commits related to this issue
- Pin version of `nwsapi` (revert later) The latest version of `nwsapi` (which is a peer dependency of `jest-environment-jsdom > jsdom`) causes `ReferenceError: document is not defined` errors in some ... — committed to vercel/next.js by unstubbable 2 years ago
- Pin version of `nwsapi` (revert later) The latest version of `nwsapi` (which is a peer dependency of `jest-environment-jsdom > jsdom`) causes `ReferenceError: document is not defined` errors in some ... — committed to vercel/next.js by unstubbable 2 years ago
- Pin version of `nwsapi` (revert later) (#73351) The latest version of `nwsapi` (which is a dependency of `jest-environment-jsdom > jsdom`) causes `ReferenceError: document is not defined` errors in... — committed to vercel/next.js by unstubbable 2 years ago
- Regen package-lock.json to avoid nwsapi bug * dperini/nwsapi#135 * #267 — committed to gjoseph/spenno by deleted user 2 years ago
- Pin version of `nwsapi` (revert later) (#73351) The latest version of `nwsapi` (which is a dependency of `jest-environment-jsdom > jsdom`) causes `ReferenceError: document is not defined` errors in... — committed to vercel/next.js by unstubbable 2 years ago
- Pin version of `nwsapi` (revert later) (#73351) The latest version of `nwsapi` (which is a dependency of `jest-environment-jsdom > jsdom`) causes `ReferenceError: document is not defined` errors in... — committed to vercel/next.js by unstubbable 2 years ago
- Pin version of `nwsapi` (revert later) (#73351) The latest version of `nwsapi` (which is a dependency of `jest-environment-jsdom > jsdom`) causes `ReferenceError: document is not defined` errors in... — committed to vercel/next.js by unstubbable 2 years ago
Adding the following to our package json fixed it for us.
Hi! Please be more carefull next time. We only had nwsapi as sub-dependency for js-dom and we had to override like someone else suggested.
Updating to 2.2.15 didn’t solve this issue: https://github.com/thymikee/jest-preset-angular/issues/2883
I also get:
ReferenceError: document is not definedwhile running my Jest (ng) tests with nwsapi version 2.2.14. See issue at https://github.com/thymikee/jest-preset-angular/issues/2883.In case anyone needs this info you can lock your dependency resolutions to the last working version like so (in your
package.json):NPM:
Yarn
Hi @dperini, thanks for the quick turnaround! The latest version (2.2.16) has fixed the
document is not defined errorin our Jest tests, but now there’s a different one:https://github.com/dperini/nwsapi/pull/134
@arqex yes the most adequate should have been ‘doc’. However in the hurry-up it was fixed slightly in a different way. The next release will hopefully be like you said, but there are rewrites too.
@maf248 Sure , will call before ! Out of pure sarcasm … are you sure there isn’t a different approach that will let us avoid depending on my time, my humor or my capabilities ? A simple checkbox that defer publishing until all dependencies have agreed and are satisfied.
I can confirm my tests run by downgrading to 2.2.13:
npm install nwsapi@2.2.13