jest-puppeteer
jest-puppeteer copied to clipboard
runScript is not defined
💥 Regression Report
Tests don't run in an environment set up with runScript
function when using jest version 24.9.0
and jest-environment-puppeteer 5.0.4
.
Last working version
Worked up to version: 5.0.3
Stopped working in version: 5.0.4
To Reproduce
Run tests in an environment set up with the runScript
function with jest version less than 27.0.0
, and jest-environment-puppeteer 5.0.4
.
Expected behavior
Tests fail with "runScript is not defined" error.
Explanation
This method was deprecated in jest 27.0.0
(and by extension in jest-environment-node) for test environment.
Looks like we would just need to add a runScript
method like https://github.com/facebook/jest/blob/2f6931e91d5ab126de70caf150c68709752e7f6c/packages/jest-environment-node/src/index.ts#L109-L114
And add a test or two.
If you want to create a PR I would be happy to review it :+1:
Yes, I have the same issue when running on[email protected]
and [email protected]
. I am a bit restricted to the jest version since, it is the version from create-react-app@3
.
I get this error:
FAIL test/unit/__tests__/dummy.test.js
● Test suite failed to run
TypeError: this._environment.runScript is not a function
at Runtime._execModule (node_modules/jest-runtime/build/index.js:856:41)
I can fix the testEnvironment variable in the jest config to node and it will work, but page
and browser
are not in the globals. But at least it runs. I am not using the react-scripts test commands but the jest commands directly.
I also added the runScript to the jest-environment-puppeteer
, which solved the problem, but then the page and browser globals are still not available.
with:
import 'expect-puppeteer'
cross-env DEBUG=test \
JEST_PUPPETEER_CONFIG=./test/visual/jest-puppeteer.config.js \
jest --runInBand --detectOpenHandles --config=./test/visual/jest.config.js
Please upgrade to v8 and reopen submit a new issue if you experience this problem.