4

I am publishing a react component to npm package, I added Webpack, babel, linting, and test to it, initially Webpack builds successfully, tests were running successfully, but then I added linting and remove node_modules folder and then install again using npm install to verify everything, at this point test breaks, Initially I got jest not found error which I fixed by npm install jest, after that, got " ReferenceError: it is not defined", fixed by import { describe, expect, it } from "@jest/globals";, now getting " ReferenceError: document is not defined", tried multiple solutions like setting the "testEnvironment": "jsdom", tried to set global.document, but nothing is working, you can see the complete code at

https://github.com/asifsha/react-picker-cascader

enter image description here

3
  • Just in case, is jsdom still in your modules ? Commented Jun 19, 2020 at 13:40
  • Yes, I also install npm install jsdom, but getting same error Commented Jun 19, 2020 at 17:30
  • Hi @Asif, did you manage to fix it for [email protected]? I am facing same problem. Global variables are not exposed independently; global.describe and global.document are present, however describe and document are not. Commented Jun 29, 2020 at 8:17

1 Answer 1

4

In my case node upgrade did the trick. I was using node v10.13.0 and upgraded to v10.16.0. It seems that minimum version required is v10.14.2 (at least for npm package babel-jest v26.1.0)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.