Skip to content

Commit

Permalink
fix: fixes --watch mode server start&restarts (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
lakesare authored and gregberge committed Dec 18, 2019
1 parent 61d04c7 commit d49a6a1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/jest-environment-puppeteer/src/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { readConfig, getPuppeteer } from './readConfig'

let browser

let didAlreadyRunInWatchMode = false

export async function setup(jestConfig = {}) {
const config = await readConfig()
const puppeteer = getPuppeteer(config)
Expand All @@ -20,7 +22,11 @@ export async function setup(jestConfig = {}) {
}
process.env.PUPPETEER_WS_ENDPOINT = browser.wsEndpoint()

if (jestConfig.watch || jestConfig.watchAll) return
// If we are in watch mode, - only setupServer() once.
if (jestConfig.watch || jestConfig.watchAll) {
if (didAlreadyRunInWatchMode) return
didAlreadyRunInWatchMode = true
}

if (config.server) {
try {
Expand Down

0 comments on commit d49a6a1

Please sign in to comment.