Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: restart worker fixtures after test failure (#3021)

Dmitry Gozman13c3f7243c6a
diff --git a/test/jest/playwrightEnvironment.js b/test/jest/playwrightEnvironment.js
index 1e65972e60..65ea360416 100644
--- a/test/jest/playwrightEnvironment.js
+++ b/test/jest/playwrightEnvironment.js
@@ -75,7 +75,6 @@ class PlaywrightEnvironment extends NodeEnvironment {
async handleTestEvent(event, state) {
if (event.name === 'setup') {
-
this.patchToEnableFixtures(this.global, 'beforeEach');
this.patchToEnableFixtures(this.global, 'afterEach');
@@ -111,6 +110,7 @@ class PlaywrightEnvironment extends NodeEnvironment {
};
this.global.expect.extend({ toBeGolden });
}
+
if (event.name === 'test_start') {
const fn = event.test.fn;
event.test.fn = async () => {
@@ -121,6 +121,10 @@ class PlaywrightEnvironment extends NodeEnvironment {
}
};
}
+
+ if (event.name === 'test_fn_failure') {
+ await this.fixturePool.teardownScope('worker');
+ }
}
}