fix(test runner): show fixture name when worker times out (#15724)

This commit is contained in:
Dmitry Gozman 2022-07-15 13:05:48 -07:00 committed by GitHub
parent 582b5e08b2
commit a56d801352
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View file

@ -128,11 +128,25 @@ class Fixture {
}
async teardown(timeoutManager: TimeoutManager) {
if (!this._teardownWithDepsComplete)
this._teardownWithDepsComplete = this._teardownInternal(timeoutManager);
if (this._teardownWithDepsComplete) {
// When we are waiting for the teardown for the second time,
// most likely after the first time did timeout, annotate current fixture
// for better error messages.
this._setTeardownDescription(timeoutManager);
await this._teardownWithDepsComplete;
timeoutManager.setCurrentFixture(undefined);
return;
}
this._teardownWithDepsComplete = this._teardownInternal(timeoutManager);
await this._teardownWithDepsComplete;
}
private _setTeardownDescription(timeoutManager: TimeoutManager) {
const title = this.registration.customTitle || this.registration.name;
this._runnableDescription.title = this.registration.timeout !== undefined ? `Fixture "${title}"` : `tearing down "${title}"`;
timeoutManager.setCurrentFixture(this._runnableDescription);
}
private async _teardownInternal(timeoutManager: TimeoutManager) {
if (typeof this.registration.fn !== 'function')
return;
@ -146,9 +160,7 @@ class Fixture {
}
if (this._useFuncFinished) {
debugTest(`teardown ${this.registration.name}`);
const title = this.registration.customTitle || this.registration.name;
this._runnableDescription.title = this.registration.timeout !== undefined ? `Fixture "${title}"` : `tearing down "${title}"`;
timeoutManager.setCurrentFixture(this._runnableDescription);
this._setTeardownDescription(timeoutManager);
this._useFuncFinished.resolve();
await this._selfTeardownComplete;
timeoutManager.setCurrentFixture(undefined);

View file

@ -474,7 +474,7 @@ test('should not report fixture teardown timeout twice', async ({ runInlineTest
expect(result.output).toContain('Test timeout of 1000ms exceeded while tearing down "fixture".');
expect(stripAnsi(result.output)).not.toContain('pwt.test.extend'); // Should not point to the location.
// TODO: this should be "not.toContain" actually.
expect(result.output).toContain('Worker teardown timeout of 1000ms exceeded.');
expect(result.output).toContain('Worker teardown timeout of 1000ms exceeded while tearing down "fixture".');
});
test('should handle fixture teardown error after test timeout and continue', async ({ runInlineTest }) => {