test: unflake a few tests (#27519)

This commit is contained in:
Dmitry Gozman 2023-10-10 09:14:58 -07:00 committed by GitHub
parent 2776d8446b
commit d05c865389
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 13 deletions

View File

@ -188,32 +188,39 @@ it('should exclude patterns', async ({ browserType, server, browserName, headles
proxy: { server: `localhost:${server.PORT}`, bypass: '1.non.existent.domain.for.the.test, 2.non.existent.domain.for.the.test, .another.test' }
});
const page = await browser.newPage();
await page.goto('http://0.non.existent.domain.for.the.test/target.html');
expect(await page.title()).toBe('Served by the proxy');
{
const page = await browser.newPage();
await page.goto('http://0.non.existent.domain.for.the.test/target.html');
expect(await page.title()).toBe('Served by the proxy');
await page.close();
}
{
const page = await browser.newPage();
const error = await page.goto('http://1.non.existent.domain.for.the.test/target.html').catch(e => e);
expect(error.message).toBeTruthy();
await page.close();
}
{
const page = await browser.newPage();
const error = await page.goto('http://2.non.existent.domain.for.the.test/target.html').catch(e => e);
expect(error.message).toBeTruthy();
await page.close();
}
{
const page = await browser.newPage();
const error = await page.goto('http://foo.is.the.another.test/target.html').catch(e => e);
expect(error.message).toBeTruthy();
await page.close();
}
// Make sure error page commits.
if (browserName === 'chromium')
await page.waitForURL('chrome-error://chromewebdata/');
{
const page = await browser.newPage();
await page.goto('http://3.non.existent.domain.for.the.test/target.html');
expect(await page.title()).toBe('Served by the proxy');
await page.close();
}
await browser.close();

View File

@ -144,16 +144,16 @@ test('should render console', async ({ showTraceViewer, browserName }) => {
await expect(traceViewer.consoleLineMessages.nth(1)).toHaveText('Warning');
await expect(traceViewer.consoleLineMessages.nth(2)).toHaveText('Error');
await expect(traceViewer.consoleLineMessages.nth(3)).toHaveText('Unhandled exception');
// Firefox can insert layout error here.
await expect(traceViewer.consoleLineMessages.last()).toHaveText('Cheers!');
// Browsers can insert more messages between these two.
await expect(traceViewer.consoleLineMessages.filter({ hasText: 'Cheers!' })).toBeVisible();
const icons = traceViewer.consoleLines.locator('.codicon');
await expect.soft(icons.nth(0)).toHaveClass('codicon codicon-browser status-none');
await expect.soft(icons.nth(1)).toHaveClass('codicon codicon-browser status-warning');
await expect.soft(icons.nth(2)).toHaveClass('codicon codicon-browser status-error');
await expect.soft(icons.nth(3)).toHaveClass('codicon codicon-browser status-error');
// Firefox can insert layout error here.
await expect.soft(icons.last()).toHaveClass('codicon codicon-browser status-none');
// Browsers can insert more messages between these two.
await expect.soft(traceViewer.consoleLines.filter({ hasText: 'Cheers!' }).locator('.codicon')).toHaveClass('codicon codicon-browser status-none');
await expect(traceViewer.consoleStacks.first()).toContainText('Error: Unhandled exception');
await traceViewer.selectAction('page.evaluate');
@ -163,8 +163,8 @@ test('should render console', async ({ showTraceViewer, browserName }) => {
await expect(listViews.nth(1)).toHaveClass('list-view-entry warning');
await expect(listViews.nth(2)).toHaveClass('list-view-entry error');
await expect(listViews.nth(3)).toHaveClass('list-view-entry error');
// Firefox can insert layout error here.
await expect(listViews.last()).toHaveClass('list-view-entry');
// Browsers can insert more messages between these two.
await expect(listViews.filter({ hasText: 'Cheers!' })).toHaveClass('list-view-entry');
});
test('should open console errors on click', async ({ showTraceViewer, browserName }) => {