Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: ignore favicon requests in page.spec event handler tests (#8208)
  • Loading branch information
juliandescottes committed Apr 7, 2022
1 parent 0955225 commit 04e5c88
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions test/page.spec.ts
Expand Up @@ -127,14 +127,20 @@ describe('Page', function () {
const { page, server } = getTestState();

const handler = sinon.spy();
page.on('response', handler);
const onResponse = (response) => {
// Ignore default favicon requests.
if (!response.url().endsWith('favicon.ico')) {
handler();
}
};
page.on('response', onResponse);
await page.goto(server.EMPTY_PAGE);
expect(handler.callCount).toBe(1);
page.off('response', handler);
page.off('response', onResponse);
await page.goto(server.EMPTY_PAGE);
// Still one because we removed the handler.
expect(handler.callCount).toBe(1);
page.on('response', handler);
page.on('response', onResponse);
await page.goto(server.EMPTY_PAGE);
// Two now because we added the handler back.
expect(handler.callCount).toBe(2);
Expand All @@ -144,14 +150,21 @@ describe('Page', function () {
const { page, server } = getTestState();

const handler = sinon.spy();
page.on('request', handler);
const onResponse = (response) => {
// Ignore default favicon requests.
if (!response.url().endsWith('favicon.ico')) {
handler();
}
};

page.on('request', onResponse);
await page.goto(server.EMPTY_PAGE);
expect(handler.callCount).toBe(1);
page.off('request', handler);
page.off('request', onResponse);
await page.goto(server.EMPTY_PAGE);
// Still one because we removed the handler.
expect(handler.callCount).toBe(1);
page.on('request', handler);
page.on('request', onResponse);
await page.goto(server.EMPTY_PAGE);
// Two now because we added the handler back.
expect(handler.callCount).toBe(2);
Expand Down

0 comments on commit 04e5c88

Please sign in to comment.