From adafcc2613934b43cf44e0c01fb8faf6f6640adc Mon Sep 17 00:00:00 2001 From: Luca Capra Date: Tue, 23 Nov 2021 06:10:42 +0100 Subject: [PATCH] fix: Catch exceptions on browser close or disconnect during teardown (#453) --- packages/jest-environment-puppeteer/src/global.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/jest-environment-puppeteer/src/global.js b/packages/jest-environment-puppeteer/src/global.js index c668b08d..b6bda0dd 100644 --- a/packages/jest-environment-puppeteer/src/global.js +++ b/packages/jest-environment-puppeteer/src/global.js @@ -77,9 +77,13 @@ export async function teardown(jestConfig = {}) { await Promise.all( browsers.map((browser) => { if (config.connect) { - return browser.disconnect() + return browser.disconnect().catch((e) => { + console.error(`global.js teardown: Error disconnecting browser ${e.stack}`) + }) } - return browser.close() + return browser.close().catch((e) => { + console.error(`global.js teardown: Error closing browser ${e.stack}`) + }) }), )