test: unflake some timeout-dependent tests (#19139)
This commit is contained in:
parent
90e3194482
commit
23e02dd006
|
|
@ -435,18 +435,14 @@ test('should respect expect.timeout', async ({ runInlineTest }) => {
|
||||||
|
|
||||||
test('timeout', async ({ page }) => {
|
test('timeout', async ({ page }) => {
|
||||||
await page.goto('data:text/html,<div>A</div>');
|
await page.goto('data:text/html,<div>A</div>');
|
||||||
await Promise.all([
|
const error = await expect(page).toHaveURL('data:text/html,<div>B</div>').catch(e => e);
|
||||||
expect(page).toHaveURL('data:text/html,<div>B</div>'),
|
expect(error.message).toContain('expect.toHaveURL with timeout 1000ms');
|
||||||
new Promise(f => setTimeout(f, 2000)).then(() => expect(true).toBe(false))
|
expect(error.message).toContain('data:text/html,<div>');
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
}, { workers: 1 });
|
}, { workers: 1 });
|
||||||
const output = stripAnsi(result.output);
|
expect(result.exitCode).toBe(0);
|
||||||
expect(output).toContain('expect(received).toHaveURL(expected)');
|
expect(result.passed).toBe(1);
|
||||||
expect(output).toContain('expect.toHaveURL with timeout 1000ms');
|
|
||||||
expect(result.failed).toBe(1);
|
|
||||||
expect(result.exitCode).toBe(1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should log scale the time', async ({ runInlineTest }) => {
|
test('should log scale the time', async ({ runInlineTest }) => {
|
||||||
|
|
|
||||||
|
|
@ -716,14 +716,14 @@ test('test.setTimeout should work separately in beforeAll', async ({ runInlineTe
|
||||||
const { test } = pwt;
|
const { test } = pwt;
|
||||||
test.beforeAll(async () => {
|
test.beforeAll(async () => {
|
||||||
console.log('\\n%%beforeAll');
|
console.log('\\n%%beforeAll');
|
||||||
test.setTimeout(100);
|
test.setTimeout(1000);
|
||||||
});
|
});
|
||||||
test('passed', async () => {
|
test('passed', async () => {
|
||||||
console.log('\\n%%test');
|
console.log('\\n%%test');
|
||||||
await new Promise(f => setTimeout(f, 500));
|
await new Promise(f => setTimeout(f, 2000));
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
}, { timeout: 2000 });
|
}, { timeout: 3000 });
|
||||||
expect(result.exitCode).toBe(0);
|
expect(result.exitCode).toBe(0);
|
||||||
expect(result.passed).toBe(1);
|
expect(result.passed).toBe(1);
|
||||||
expect(result.output.split('\n').filter(line => line.startsWith('%%'))).toEqual([
|
expect(result.output.split('\n').filter(line => line.startsWith('%%'))).toEqual([
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue