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

jsdomstill in your modules ?global.describeandglobal.documentare present, howeverdescribeanddocumentare not.