Skip to content

Commit

Permalink
test: unflake a few tests (#27519)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgozman committed Oct 10, 2023
1 parent 2776d84 commit d05c865
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
21 changes: 14 additions & 7 deletions tests/library/proxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions tests/library/trace-viewer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 }) => {
Expand Down

0 comments on commit d05c865

Please sign in to comment.