Reputation: 73
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
Upvotes: 4
Views: 7927
Reputation: 384
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)
Upvotes: 4