fix(test runner): test.setTimeout whould not break debugging (#11004)

We ignore test.setTimeout() when timeout is already zero for debugging.
This commit is contained in:
Dmitry Gozman 2021-12-17 15:17:48 -08:00 committed by GitHub
parent f5780be41b
commit b6aad54b9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -329,6 +329,8 @@ export class WorkerRunner extends EventEmitter {
fail: (...args: [arg?: any, description?: string]) => modifier(testInfo, 'fail', args),
slow: (...args: [arg?: any, description?: string]) => modifier(testInfo, 'slow', args),
setTimeout: (timeout: number) => {
if (!testInfo.timeout)
return; // Zero timeout means some debug mode - do not set a timeout.
testInfo.timeout = timeout;
if (deadlineRunner)
deadlineRunner.updateDeadline(deadline());

View file

@ -140,3 +140,17 @@ test('should respect test.slow', async ({ runInlineTest }) => {
expect(result.passed).toBe(2);
expect(result.output).toContain('Timeout of 1000ms exceeded');
});
test('should ignore test.setTimeout when debugging', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.spec.ts': `
const { test } = pwt;
test('my test', async ({}) => {
test.setTimeout(1000);
await new Promise(f => setTimeout(f, 2000));
});
`
}, { timeout: 0 });
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
});