Jest with puppeteer using existing chrome browser

1.7k views Asked by At

I am trying to make puppeteer work with Jest for e2e testing while using existing Chrome browser.

I choose my puppeteer version "5.1.0" for chrome browser version "84.0.4147" from the list of supported browsers.

I am trying to configure Jest with puppeteer using the information aviable at the following link

Jest Puppeteer configuration using jest-puppeteer

apparently puppeteer library tried to download chromium browser binary which i have skip b/c i would like to use existing chrome browser. and i am having hard time configuring that.

There is some help here at jest puppeteer preset documentation but still not enough help how to use existing browser.

I am assuming using existing chrome configuration should be in jest.puppeteer.config.js but don't know yet how to do it !

Rite now my jest-puppeteer.config.js looks as following

module.exports = {

launch: {
headless: false,
slowMo: false
devtools:true
},
browser: 'chromium'
browserContext: 'default'

}

when i run my tests, i get following error

Error: Could not find browser revision 800071. Run "PUPPETEER_PRODUCT=firefox 7pm install" or "PUPPETEER_PRODUCT=firefox yarn install" to download a supported Fire fox browser binary"
2

There are 2 answers

0
Aleks On

https://developers.google.com/web/tools/puppeteer/get-started

By default, Puppeteer downloads and uses a specific version of Chromium so its API is guaranteed to work out of the box. To use Puppeteer with a different version of Chrome or Chromium, pass in the executable's path when creating a Browser instance:

const browser = await puppeteer.launch({executablePath: '/path/to/Chrome'});
0
d-man On

i was still getting same error with the above answer but following solution worked for me.

https://docs.percy.io/docs/skipping-puppeteer-chromium-download