Skip to content

Commit

Permalink
fix: teardown browser in watch mode. (#270)
Browse files Browse the repository at this point in the history
When jest is running in Watch mode, each test run creates a new browser — so we’ll want to teardown the browser to avoid memory leaks.
  • Loading branch information
adunkman authored and gregberge committed Jul 23, 2019
1 parent 0d72f09 commit 04de87a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/jest-environment-puppeteer/src/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ export async function setup(jestConfig = {}) {
}

export async function teardown(jestConfig = {}) {
const config = await readConfig()

if (config.connect) {
await browser.disconnect()
} else {
await browser.close()
}

if (!jestConfig.watch && !jestConfig.watchAll) {
await teardownServer()

const config = await readConfig()
if (config.connect) {
await browser.disconnect()
} else {
await browser.close()
}
}
}

0 comments on commit 04de87a

Please sign in to comment.