test: improve target.asPage tests (#12060)

This commit is contained in:
Darío Kondratiuk 2024-03-11 07:54:55 -03:00 committed by GitHub
parent d89b739b5e
commit 4f422e60a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 8 deletions

View File

@ -2458,7 +2458,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
};
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();

View File

@ -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"],

View File

@ -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(