test: move cdp only tests to a subfolder (#11033)

Co-authored-by: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com>
This commit is contained in:
Alex Rudenko 2023-09-26 10:13:22 +02:00 committed by GitHub
parent 8993def882
commit e0e7e3a5df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 21 deletions

View File

@ -27,9 +27,4 @@ module.exports = {
parallel: !!process.env.PARALLEL, parallel: !!process.env.PARALLEL,
timeout: timeout, timeout: timeout,
reporter: process.env.CI ? 'spec' : 'dot', reporter: process.env.CI ? 'spec' : 'dot',
...(!process.env['PUPPETEER_SHARD']
? {
spec: 'test/build/**/*.spec.js',
}
: {}),
}; };

View File

@ -17,8 +17,8 @@
import expect from 'expect'; import expect from 'expect';
import {isErrorLike} from 'puppeteer-core/internal/util/ErrorLike.js'; import {isErrorLike} from 'puppeteer-core/internal/util/ErrorLike.js';
import {getTestState, setupTestBrowserHooks} from './mocha-utils.js'; import {getTestState, setupTestBrowserHooks} from '../mocha-utils.js';
import {waitEvent} from './utils.js'; import {waitEvent} from '../utils.js';
describe('Target.createCDPSession', function () { describe('Target.createCDPSession', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -17,8 +17,8 @@
import expect from 'expect'; import expect from 'expect';
import {type CdpBrowser} from 'puppeteer-core/internal/cdp/Browser.js'; import {type CdpBrowser} from 'puppeteer-core/internal/cdp/Browser.js';
import {getTestState, launch} from './mocha-utils.js'; import {getTestState, launch} from '../mocha-utils.js';
import {attachFrame} from './utils.js'; import {attachFrame} from '../utils.js';
describe('TargetManager', () => { describe('TargetManager', () => {
/* We use a special browser for this test as we need the --site-per-process flag */ /* We use a special browser for this test as we need the --site-per-process flag */

View File

@ -17,8 +17,8 @@
import expect from 'expect'; import expect from 'expect';
import {PageEvent} from 'puppeteer-core'; import {PageEvent} from 'puppeteer-core';
import {launch} from './mocha-utils.js'; import {launch} from '../mocha-utils.js';
import {waitEvent} from './utils.js'; import {waitEvent} from '../utils.js';
describe('BFCache', function () { describe('BFCache', function () {
it('can navigate to a BFCached page', async () => { it('can navigate to a BFCached page', async () => {

View File

@ -16,7 +16,7 @@
import expect from 'expect'; import expect from 'expect';
import {getTestState, setupTestBrowserHooks} from './mocha-utils.js'; import {getTestState, setupTestBrowserHooks} from '../mocha-utils.js';
describe('Prerender', function () { describe('Prerender', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -79,6 +79,7 @@ function getApplicableTestSuites(
async function main() { async function main() {
const noCoverage = process.argv.indexOf('--no-coverage') !== -1; const noCoverage = process.argv.indexOf('--no-coverage') !== -1;
const noSuggestions = process.argv.indexOf('--no-suggestions') !== -1; const noSuggestions = process.argv.indexOf('--no-suggestions') !== -1;
const excludeCDPOnly = process.argv.indexOf('--no-cdp-tests') !== -1;
const statsFilenameIdx = process.argv.indexOf('--save-stats-to'); const statsFilenameIdx = process.argv.indexOf('--save-stats-to');
let statsFilename = ''; let statsFilename = '';
@ -192,10 +193,14 @@ async function main() {
if (process.argv.indexOf('--fullTrace')) { if (process.argv.indexOf('--fullTrace')) {
args.push('--full-trace'); args.push('--full-trace');
} }
if (shard) {
const specs = globSync('test/build/**/*.spec.js').sort((a, b) => { const specPattern = 'test/build/**/*.spec.js';
const specs = globSync(specPattern, {
ignore: excludeCDPOnly ? 'test/build/cdp/**/*.spec.js' : undefined,
}).sort((a, b) => {
return a.localeCompare(b); return a.localeCompare(b);
}); });
if (shard) {
// Shard ID is 1-based. // Shard ID is 1-based.
const [shardId, shards] = shard.split('/').map(s => { const [shardId, shards] = shard.split('/').map(s => {
return Number(s); return Number(s);
@ -214,17 +219,14 @@ async function main() {
args.length - argsLength args.length - argsLength
} files out of ${specs.length}.` } files out of ${specs.length}.`
); );
} else {
args.push(...specs);
} }
const spawnArgs: SpawnOptions = { const spawnArgs: SpawnOptions = {
shell: true, shell: true,
cwd: process.cwd(), cwd: process.cwd(),
stdio: 'inherit', stdio: 'inherit',
env: shard env,
? {
...env,
PUPPETEER_SHARD: 'true',
}
: env,
}; };
const handle = noCoverage const handle = noCoverage
? spawn('npx', ['mocha', ...args], spawnArgs) ? spawn('npx', ['mocha', ...args], spawnArgs)