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

This way previous test that leaves browser in a bad state does not
affect future tests.
This commit is contained in:
Dmitry Gozman 2020-07-17 19:54:37 -07:00 committed by GitHub
parent 562e1e6460
commit 13c3f7243c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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