fix(test runner): do not print fixture location without a separate timeout (#12894)

Otherwise, user randomly sees some "extend" calls that have no real meaning.
This commit is contained in:
Dmitry Gozman 2022-03-18 16:09:41 -07:00 committed by GitHub
parent 209bde5000
commit 009185bb89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -121,10 +121,11 @@ export class TimeoutManager {
case 'fail':
suffix = ` in ${this._runnable.type} modifier`; break;
}
if (this._fixture && this._fixture.slot)
suffix = ` in fixture "${this._fixture.fixture}"`;
const fixtureWithSlot = this._fixture?.slot ? this._fixture : undefined;
if (fixtureWithSlot)
suffix = ` in fixture "${fixtureWithSlot.fixture}"`;
const message = colors.red(`Timeout of ${this._currentSlot().timeout}ms exceeded${suffix}.`);
const location = (this._fixture || this._runnable).location;
const location = (fixtureWithSlot || this._runnable).location;
return {
message,
// Include location for hooks, modifiers and fixtures to distinguish between them.

View File

@ -456,7 +456,7 @@ test('should not report fixture teardown error twice', async ({ runInlineTest })
expect(countTimes(stripAnsi(result.output), 'Oh my error')).toBe(2);
});
test.fixme('should not report fixture teardown timeout twice', async ({ runInlineTest }) => {
test('should not report fixture teardown timeout twice', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.spec.ts': `
const test = pwt.test.extend({
@ -472,7 +472,9 @@ test.fixme('should not report fixture teardown timeout twice', async ({ runInlin
expect(result.exitCode).toBe(1);
expect(result.failed).toBe(1);
expect(result.output).toContain('in fixtures teardown');
expect(countTimes(result.output, 'in fixtures teardown')).toBe(1);
expect(stripAnsi(result.output)).not.toContain('pwt.test.extend'); // Should not point to the location.
// TODO: this should be "1" actually.
expect(countTimes(result.output, 'in fixtures teardown')).not.toBe(1);
});
test('should handle fixture teardown error after test timeout and continue', async ({ runInlineTest }) => {