[Help needed] mixed use of jest-environment-puppeteer and jest-enviroment-jsdom?
See original GitHub issue💬 Questions and Help
Hey there: I am new to jest and jest-puppeteer, and meet some problems: In my project, some test suites are jsDom based and some are puppeteer based. By the jest doc, we can assign different ENV to different files with a docblock like
/**
- @jest-environment jest-environment-puppeteer */
So I put this docblock to my puppeteer-based test suites, and leave the others intact (since jest-enviroment-jsdom is the default test ENV)
I give it a try, but see that the code throws at the following(PuppeteerEnviroment.js):
async setup() {
const config = await readConfig()
this.global.puppeteerConfig = config
const wsEndpoint = process.env.PUPPETEER_WS_ENDPOINT
if (!wsEndpoint) {
throw new Error('wsEndpoint not found')
}
Basically, it seems I need to set the node ENV variable (PUPPETEER_WS_ENDPOINT), but what does it mean? What’s its format like? Can you shed some light?
Note that if I use the jest-puppeter as the preset in jest.config.js, and skip those jsDom based test cases, things are running fine. I am wondering what is happening behind the scene?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
https://github.com/smooth-code/jest-puppeteer/issues/234 i see this, add this block code to any test file’s head
it works well
Thanks for the tip @xiaoyuhen Again, this is setting the global test ENV for JEST, and in our case, the test suite based on JSDOM will fail like:
But I think I find a workaround, that is to make jest-environment-puppeteer the default test ENV and meanwhile add a doc block to JSDOM-based test suites like
This will get different test suites correctly set-up.