diff --git a/packages/jest-environment-puppeteer/src/global.js b/packages/jest-environment-puppeteer/src/global.js index 2f0913d0..1bdeb96d 100644 --- a/packages/jest-environment-puppeteer/src/global.js +++ b/packages/jest-environment-puppeteer/src/global.js @@ -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() - } } }