Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore favicon requests in page.spec event handler tests #8208

Merged
merged 1 commit into from Apr 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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