Closed igorpupkinable closed 2 years ago
Hey @igorpupkinable!
It looks like the error stack your provided is referencing the browser bundle of @percy/sdk-utils
node_modules/@percy/sdk-utils/dist/bundle.js
This should only be used in browser environments (where window
would be available). For node, it should be using the main/node exports defined by the package.json: https://github.com/percy/cli/blob/master/packages/sdk-utils/package.json#L22-L28
Since you say this is only an issue when upgrading jest, it sounds like they might have changed their bespoke module loader which is not honoring native node module loading.
@wwilsman hi, have the same issue with stack:
"engines": { "node": ">=16.16 <17", "npm": ">=8.13.2" }, "dependencies": { "puppeteer": "^14.0.0" }, "devDependencies": { "@percy/cli": "^1.1.3", "@percy/puppeteer": "^2.0.2", "eslint": "^8.15.0", "jest": "^28.1.0", "jest-circus": "^28.1.0", "jest-puppeteer": "^6.1.0", "puppeteer-core": "^14.0.0" }
and it was working fine for last few months until few days ago. There were no changes from my side to the setup or tests.
Trying to find a way how to just return state back to normal and get running tests as before.
UPD:
Resolved my issue just with downgrading above list to exact versions without updates, like "@percy/cli": "1.1.3"
instead of "@percy/cli": "^1.1.3"
.
Would be happy to update them once resolved.
Hey @frixatrix! It sounds like Jest is broken in how they're importing modules. In a later version we updated how the export works to match the spec(s): https://github.com/percy/cli/pull/962
This issue is stale because it has been open for more than 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue was closed because it has been stalled for 28 days with no activity.
The problem
ReferenceError: window is not defined
is thrown after upgrading to Jest 28. Same setup works fine with Jest 27 though.Environment
@percy/cli
version: 1.6.0Details
ReferenceError: window is not defined
error occurs when referencingpercySnapshot
method after upgrading to Jest 28. Installing JSDOM environment explicitly does not help either. https://jestjs.io/docs/upgrading-to-jest28#jsdomDebug logs
Code to reproduce issue
Install Jest 28 and configure latest
jest-puppeteer
as per documentation https://jestjs.io/docs/28.0/puppeteer#use-jest-puppeteer-preset Run simple test: