From 4f422e60a65011459f38eae3def3cf9d78161d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Mon, 11 Mar 2024 07:54:55 -0300 Subject: [PATCH] test: improve `target.asPage` tests (#12060) --- packages/puppeteer-core/src/api/Page.ts | 2 +- test/TestExpectations.json | 8 ++++---- test/src/cdp/devtools.spec.ts | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/puppeteer-core/src/api/Page.ts b/packages/puppeteer-core/src/api/Page.ts index b094d14b2fe..2ad18466ea6 100644 --- a/packages/puppeteer-core/src/api/Page.ts +++ b/packages/puppeteer-core/src/api/Page.ts @@ -2458,7 +2458,7 @@ export abstract class Page extends EventEmitter { }; if (options.type === undefined && options.path !== undefined) { const filePath = options.path; - // Note we cannot use Node.js here due to browser compatability. + // Note we cannot use Node.js here due to browser compatibility. const extension = filePath .slice(filePath.lastIndexOf('.') + 1) .toLowerCase(); diff --git a/test/TestExpectations.json b/test/TestExpectations.json index 53e25f385b6..bb666ef7e69 100644 --- a/test/TestExpectations.json +++ b/test/TestExpectations.json @@ -363,14 +363,14 @@ "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, { - "testIdPattern": "[devtools.spec] DevTools target.page() should return a DevTools page if asPage is used", + "testIdPattern": "[devtools.spec] DevTools target.page() should return a DevTools page if custom isPageTarget is provided", "platforms": ["darwin", "linux", "win32"], "parameters": ["firefox"], "expectations": ["SKIP"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, { - "testIdPattern": "[devtools.spec] DevTools target.page() should return a DevTools page if custom isPageTarget is provided", + "testIdPattern": "[devtools.spec] DevTools target.page() should return Page when calling asPage on DevTools target", "platforms": ["darwin", "linux", "win32"], "parameters": ["firefox"], "expectations": ["SKIP"], @@ -3831,14 +3831,14 @@ "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, { - "testIdPattern": "[devtools.spec] DevTools target.page() should return a DevTools page if asPage is used", + "testIdPattern": "[devtools.spec] DevTools target.page() should return a DevTools page if custom isPageTarget is provided", "platforms": ["darwin", "linux", "win32"], "parameters": ["cdp", "chrome", "chrome-headless-shell"], "expectations": ["SKIP"], "comment": "TODO: add a comment explaining why this expectation is required (include links to issues)" }, { - "testIdPattern": "[devtools.spec] DevTools target.page() should return a DevTools page if custom isPageTarget is provided", + "testIdPattern": "[devtools.spec] DevTools target.page() should return Page when calling asPage on DevTools target", "platforms": ["darwin", "linux", "win32"], "parameters": ["cdp", "chrome", "chrome-headless-shell"], "expectations": ["SKIP"], diff --git a/test/src/cdp/devtools.spec.ts b/test/src/cdp/devtools.spec.ts index c48b4c353b9..0f9330d15fa 100644 --- a/test/src/cdp/devtools.spec.ts +++ b/test/src/cdp/devtools.spec.ts @@ -67,9 +67,9 @@ describe('DevTools', function () { return 2 * 3; }) ).toBe(6); - expect(await browser.pages()).toContainEqual(page); + expect(await browser.pages()).toContain(page); }); - it('target.page() should return a DevTools page if asPage is used', async function () { + it('target.page() should return Page when calling asPage on DevTools target', async function () { const {puppeteer} = await getTestState({skipLaunch: true}); const originalBrowser = await launchBrowser(launchOptions); @@ -87,7 +87,8 @@ describe('DevTools', function () { return 2 * 3; }) ).toBe(6); - expect(await browser.pages()).toContainEqual(page); + // The page won't be part of browser.pages() if a custom isPageTarget is not provided + expect(await browser.pages()).not.toContain(page); }); it('should open devtools when "devtools: true" option is given', async () => { const browser = await launchBrowser(