Skip to content

Commit

Permalink
feat: can set chrome executable path through env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmurray committed Sep 15, 2019
1 parent 55d8625 commit e37e2f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/global-hooks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import puppeteer from 'puppeteer'

const globalSetup = async () => {
;(global as any).browser = await puppeteer.launch()
;(global as any).browser = await puppeteer.launch({
executablePath: process.env.CHROME_EXECUTABLE_PATH,
})
process.env.PUPPETEER_WS_ENDPOINT = (global as any).browser.wsEndpoint()
}

Expand Down
4 changes: 3 additions & 1 deletion src/puppeteer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const loadPage = async () => {
? puppeteer.connect({
browserWSEndpoint: process.env.PUPPETEER_WS_ENDPOINT,
})
: puppeteer.launch())
: puppeteer.launch({
executablePath: process.env.CHROME_EXECUTABLE_PATH,
}))

const page = await browser.newPage()

Expand Down

0 comments on commit e37e2f7

Please sign in to comment.