print warning for successful tests only

This commit is contained in:
Andrey Lushnikov 2020-02-19 16:07:11 -08:00
parent 8bb4996ea8
commit fb810428ad

View file

@ -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();
});