Skip to content

Commit d05c865

Browse files
authored
test: unflake a few tests (#27519)
1 parent 2776d84 commit d05c865

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

tests/library/proxy.spec.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,32 +188,39 @@ it('should exclude patterns', async ({ browserType, server, browserName, headles
188188
proxy: { server: `localhost:${server.PORT}`, bypass: '1.non.existent.domain.for.the.test, 2.non.existent.domain.for.the.test, .another.test' }
189189
});
190190

191-
const page = await browser.newPage();
192-
await page.goto('http://0.non.existent.domain.for.the.test/target.html');
193-
expect(await page.title()).toBe('Served by the proxy');
191+
{
192+
const page = await browser.newPage();
193+
await page.goto('http://0.non.existent.domain.for.the.test/target.html');
194+
expect(await page.title()).toBe('Served by the proxy');
195+
await page.close();
196+
}
194197

195198
{
199+
const page = await browser.newPage();
196200
const error = await page.goto('http://1.non.existent.domain.for.the.test/target.html').catch(e => e);
197201
expect(error.message).toBeTruthy();
202+
await page.close();
198203
}
199204

200205
{
206+
const page = await browser.newPage();
201207
const error = await page.goto('http://2.non.existent.domain.for.the.test/target.html').catch(e => e);
202208
expect(error.message).toBeTruthy();
209+
await page.close();
203210
}
204211

205212
{
213+
const page = await browser.newPage();
206214
const error = await page.goto('http://foo.is.the.another.test/target.html').catch(e => e);
207215
expect(error.message).toBeTruthy();
216+
await page.close();
208217
}
209218

210-
// Make sure error page commits.
211-
if (browserName === 'chromium')
212-
await page.waitForURL('chrome-error://chromewebdata/');
213-
214219
{
220+
const page = await browser.newPage();
215221
await page.goto('http://3.non.existent.domain.for.the.test/target.html');
216222
expect(await page.title()).toBe('Served by the proxy');
223+
await page.close();
217224
}
218225

219226
await browser.close();

tests/library/trace-viewer.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,16 @@ test('should render console', async ({ showTraceViewer, browserName }) => {
144144
await expect(traceViewer.consoleLineMessages.nth(1)).toHaveText('Warning');
145145
await expect(traceViewer.consoleLineMessages.nth(2)).toHaveText('Error');
146146
await expect(traceViewer.consoleLineMessages.nth(3)).toHaveText('Unhandled exception');
147-
// Firefox can insert layout error here.
148-
await expect(traceViewer.consoleLineMessages.last()).toHaveText('Cheers!');
147+
// Browsers can insert more messages between these two.
148+
await expect(traceViewer.consoleLineMessages.filter({ hasText: 'Cheers!' })).toBeVisible();
149149

150150
const icons = traceViewer.consoleLines.locator('.codicon');
151151
await expect.soft(icons.nth(0)).toHaveClass('codicon codicon-browser status-none');
152152
await expect.soft(icons.nth(1)).toHaveClass('codicon codicon-browser status-warning');
153153
await expect.soft(icons.nth(2)).toHaveClass('codicon codicon-browser status-error');
154154
await expect.soft(icons.nth(3)).toHaveClass('codicon codicon-browser status-error');
155-
// Firefox can insert layout error here.
156-
await expect.soft(icons.last()).toHaveClass('codicon codicon-browser status-none');
155+
// Browsers can insert more messages between these two.
156+
await expect.soft(traceViewer.consoleLines.filter({ hasText: 'Cheers!' }).locator('.codicon')).toHaveClass('codicon codicon-browser status-none');
157157
await expect(traceViewer.consoleStacks.first()).toContainText('Error: Unhandled exception');
158158

159159
await traceViewer.selectAction('page.evaluate');
@@ -163,8 +163,8 @@ test('should render console', async ({ showTraceViewer, browserName }) => {
163163
await expect(listViews.nth(1)).toHaveClass('list-view-entry warning');
164164
await expect(listViews.nth(2)).toHaveClass('list-view-entry error');
165165
await expect(listViews.nth(3)).toHaveClass('list-view-entry error');
166-
// Firefox can insert layout error here.
167-
await expect(listViews.last()).toHaveClass('list-view-entry');
166+
// Browsers can insert more messages between these two.
167+
await expect(listViews.filter({ hasText: 'Cheers!' })).toHaveClass('list-view-entry');
168168
});
169169

170170
test('should open console errors on click', async ({ showTraceViewer, browserName }) => {

0 commit comments

Comments
 (0)