Skip to content

Commit

Permalink
test: restart worker fixtures after test failure (#3021)
Browse files Browse the repository at this point in the history
This way previous test that leaves browser in a bad state does not
affect future tests.
  • Loading branch information
dgozman committed Jul 18, 2020
1 parent 562e1e6 commit 13c3f72
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/jest/playwrightEnvironment.js
Expand Up @@ -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');

Expand Down Expand Up @@ -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 () => {
Expand All @@ -121,6 +121,10 @@ class PlaywrightEnvironment extends NodeEnvironment {
}
};
}

if (event.name === 'test_fn_failure') {
await this.fixturePool.teardownScope('worker');
}
}
}

Expand Down

0 comments on commit 13c3f72

Please sign in to comment.