From fb810428ad9f71eb9f4ef877f0099352904b396f Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Wed, 19 Feb 2020 16:07:11 -0800 Subject: [PATCH] print warning for successful tests only --- test/playwright.spec.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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(); });