test: move skipped tests to expectations (#11789)

This commit is contained in:
Alex Rudenko 2024-01-30 17:42:49 +01:00 committed by GitHub
parent b99d478cd4
commit 422b5a5b03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 67 additions and 69 deletions

View File

@ -689,18 +689,6 @@
"parameters": ["firefox"],
"expectations": ["SKIP"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.launch should work with no default arguments",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome"],
"expectations": ["SKIP"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.launch should work with no default arguments",
"platforms": ["linux"],
"parameters": ["webDriverBiDi"],
"expectations": ["FAIL"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.launch should work with no default arguments",
"platforms": ["darwin", "linux", "win32"],
@ -1111,6 +1099,18 @@
"parameters": ["firefox"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[screenshot.spec] Screenshots Cdp should work in \"fromSurface: false\" mode",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["headless"],
"expectations": ["SKIP"]
},
{
"testIdPattern": "[screenshot.spec] Screenshots Cdp should work in \"fromSurface: false\" mode",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["new-headless"],
"expectations": ["SKIP"]
},
{
"testIdPattern": "[screenshot.spec] Screenshots Page.screenshot should get screenshot bigger than the viewport",
"platforms": ["darwin", "linux", "win32"],
@ -2245,6 +2245,18 @@
"parameters": ["cdp", "firefox"],
"expectations": ["FAIL", "PASS"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.launch should work with no default arguments",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "headless"],
"expectations": ["SKIP"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.launch should work with no default arguments",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "new-headless"],
"expectations": ["SKIP"]
},
{
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.launch tmp profile should be cleaned up",
"platforms": ["darwin", "linux", "win32"],

View File

@ -16,7 +16,7 @@ import type {Page} from 'puppeteer-core/internal/api/Page.js';
import {rmSync} from 'puppeteer-core/internal/node/util/fs.js';
import sinon from 'sinon';
import {getTestState, isHeadless, launch} from './mocha-utils.js';
import {getTestState, launch} from './mocha-utils.js';
import {dumpFrames, waitEvent} from './utils.js';
const TMP_FOLDER = path.join(os.tmpdir(), 'pptr_tmp_folder-');
@ -408,21 +408,18 @@ describe('Launcher specs', function () {
expect(puppeteer.product).toBe('firefox');
}
});
(!isHeadless ? it : it.skip)(
'should work with no default arguments',
async () => {
const {context, close} = await launch({
ignoreDefaultArgs: true,
});
try {
const page = await context.newPage();
expect(await page.evaluate('11 * 11')).toBe(121);
await page.close();
} finally {
await close();
}
it('should work with no default arguments', async () => {
const {context, close} = await launch({
ignoreDefaultArgs: true,
});
try {
const page = await context.newPage();
expect(await page.evaluate('11 * 11')).toBe(121);
await page.close();
} finally {
await close();
}
);
});
it('should filter out ignored default arguments in Chrome', async () => {
const {defaultBrowserOptions, puppeteer} = await getTestState({
skipLaunch: true,
@ -590,31 +587,28 @@ describe('Launcher specs', function () {
});
expect(error.message).toContain('either pipe or debugging port');
});
(!isHeadless ? it : it.skip)(
'should launch Chrome properly with --no-startup-window and waitForInitialPage=false',
async () => {
const {defaultBrowserOptions} = await getTestState({
skipLaunch: true,
});
const options = {
waitForInitialPage: false,
// This is needed to prevent Puppeteer from adding an initial blank page.
// See also https://github.com/puppeteer/puppeteer/blob/ad6b736039436fcc5c0a262e5b575aa041427be3/src/node/Launcher.ts#L200
ignoreDefaultArgs: true,
...defaultBrowserOptions,
args: ['--no-startup-window'],
};
const {browser, close} = await launch(options, {
createContext: false,
});
try {
const pages = await browser.pages();
expect(pages).toHaveLength(0);
} finally {
await close();
}
it('should launch Chrome properly with --no-startup-window and waitForInitialPage=false', async () => {
const {defaultBrowserOptions} = await getTestState({
skipLaunch: true,
});
const options = {
waitForInitialPage: false,
// This is needed to prevent Puppeteer from adding an initial blank page.
// See also https://github.com/puppeteer/puppeteer/blob/ad6b736039436fcc5c0a262e5b575aa041427be3/src/node/Launcher.ts#L200
ignoreDefaultArgs: true,
...defaultBrowserOptions,
args: ['--no-startup-window'],
};
const {browser, close} = await launch(options, {
createContext: false,
});
try {
const pages = await browser.pages();
expect(pages).toHaveLength(0);
} finally {
await close();
}
);
});
});
describe('Puppeteer.launch', function () {

View File

@ -8,12 +8,7 @@ import assert from 'assert';
import expect from 'expect';
import {
getTestState,
isHeadless,
launch,
setupTestBrowserHooks,
} from './mocha-utils.js';
import {getTestState, launch, setupTestBrowserHooks} from './mocha-utils.js';
describe('Screenshots', function () {
setupTestBrowserHooks();
@ -436,18 +431,15 @@ describe('Screenshots', function () {
});
expect(screenshot).toBeGolden('white.jpg');
});
(!isHeadless ? it : it.skip)(
'should work in "fromSurface: false" mode',
async () => {
const {page, server} = await getTestState();
it('should work in "fromSurface: false" mode', async () => {
const {page, server} = await getTestState();
await page.setViewport({width: 500, height: 500});
await page.goto(server.PREFIX + '/grid.html');
const screenshot = await page.screenshot({
fromSurface: false,
});
expect(screenshot).toBeDefined(); // toBeGolden('screenshot-fromsurface-false.png');
}
);
await page.setViewport({width: 500, height: 500});
await page.goto(server.PREFIX + '/grid.html');
const screenshot = await page.screenshot({
fromSurface: false,
});
expect(screenshot).toBeDefined();
});
});
});