Skip to content

Commit 13c3f72

Browse files
authored
test: restart worker fixtures after test failure (#3021)
This way previous test that leaves browser in a bad state does not affect future tests.
1 parent 562e1e6 commit 13c3f72

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/jest/playwrightEnvironment.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ class PlaywrightEnvironment extends NodeEnvironment {
7575

7676
async handleTestEvent(event, state) {
7777
if (event.name === 'setup') {
78-
7978
this.patchToEnableFixtures(this.global, 'beforeEach');
8079
this.patchToEnableFixtures(this.global, 'afterEach');
8180

@@ -111,6 +110,7 @@ class PlaywrightEnvironment extends NodeEnvironment {
111110
};
112111
this.global.expect.extend({ toBeGolden });
113112
}
113+
114114
if (event.name === 'test_start') {
115115
const fn = event.test.fn;
116116
event.test.fn = async () => {
@@ -121,6 +121,10 @@ class PlaywrightEnvironment extends NodeEnvironment {
121121
}
122122
};
123123
}
124+
125+
if (event.name === 'test_fn_failure') {
126+
await this.fixturePool.teardownScope('worker');
127+
}
124128
}
125129
}
126130

0 commit comments

Comments
 (0)