diff --git a/test/playwright.spec.js b/test/playwright.spec.js index a546c3bb21..2caacea451 100644 --- a/test/playwright.spec.js +++ b/test/playwright.spec.js @@ -134,8 +134,11 @@ module.exports.describe = ({testRunner, product, playwrightPath}) => { }); afterEach(async (state, test) => { - if (state.browser.contexts().length !== 0) - console.warn(`\nWARNING: test "${test.fullName}" (${test.location.fileName}:${test.location.lineNumber}) did not close all created contexts!\n`); + if (state.browser.contexts().length !== 0) { + if (test.result === 'ok') + console.warn(`\nWARNING: test "${test.fullName}" (${test.location.fileName}:${test.location.lineNumber}) did not close all created contexts!\n`); + await Promise.all(state.browser.contexts().map(context => context.close())); + } await state.tearDown(); });