diff --git a/.mocharc.cjs b/.mocharc.cjs index fff31ff0..08f4d0f0 100644 --- a/.mocharc.cjs +++ b/.mocharc.cjs @@ -27,9 +27,4 @@ module.exports = { parallel: !!process.env.PARALLEL, timeout: timeout, reporter: process.env.CI ? 'spec' : 'dot', - ...(!process.env['PUPPETEER_SHARD'] - ? { - spec: 'test/build/**/*.spec.js', - } - : {}), }; diff --git a/test/src/CDPSession.spec.ts b/test/src/cdp/CDPSession.spec.ts similarity index 97% rename from test/src/CDPSession.spec.ts rename to test/src/cdp/CDPSession.spec.ts index 3e2d6bbc..65254f9a 100644 --- a/test/src/CDPSession.spec.ts +++ b/test/src/cdp/CDPSession.spec.ts @@ -17,8 +17,8 @@ import expect from 'expect'; import {isErrorLike} from 'puppeteer-core/internal/util/ErrorLike.js'; -import {getTestState, setupTestBrowserHooks} from './mocha-utils.js'; -import {waitEvent} from './utils.js'; +import {getTestState, setupTestBrowserHooks} from '../mocha-utils.js'; +import {waitEvent} from '../utils.js'; describe('Target.createCDPSession', function () { setupTestBrowserHooks(); diff --git a/test/src/TargetManager.spec.ts b/test/src/cdp/TargetManager.spec.ts similarity index 97% rename from test/src/TargetManager.spec.ts rename to test/src/cdp/TargetManager.spec.ts index 112db1e9..7aeb7ec1 100644 --- a/test/src/TargetManager.spec.ts +++ b/test/src/cdp/TargetManager.spec.ts @@ -17,8 +17,8 @@ import expect from 'expect'; import {type CdpBrowser} from 'puppeteer-core/internal/cdp/Browser.js'; -import {getTestState, launch} from './mocha-utils.js'; -import {attachFrame} from './utils.js'; +import {getTestState, launch} from '../mocha-utils.js'; +import {attachFrame} from '../utils.js'; describe('TargetManager', () => { /* We use a special browser for this test as we need the --site-per-process flag */ diff --git a/test/src/bfcache.spec.ts b/test/src/cdp/bfcache.spec.ts similarity index 96% rename from test/src/bfcache.spec.ts rename to test/src/cdp/bfcache.spec.ts index a9113ed5..f13e2ffa 100644 --- a/test/src/bfcache.spec.ts +++ b/test/src/cdp/bfcache.spec.ts @@ -17,8 +17,8 @@ import expect from 'expect'; import {PageEvent} from 'puppeteer-core'; -import {launch} from './mocha-utils.js'; -import {waitEvent} from './utils.js'; +import {launch} from '../mocha-utils.js'; +import {waitEvent} from '../utils.js'; describe('BFCache', function () { it('can navigate to a BFCached page', async () => { diff --git a/test/src/prerender.spec.ts b/test/src/cdp/prerender.spec.ts similarity index 98% rename from test/src/prerender.spec.ts rename to test/src/cdp/prerender.spec.ts index 307b146c..1add6d83 100644 --- a/test/src/prerender.spec.ts +++ b/test/src/cdp/prerender.spec.ts @@ -16,7 +16,7 @@ import expect from 'expect'; -import {getTestState, setupTestBrowserHooks} from './mocha-utils.js'; +import {getTestState, setupTestBrowserHooks} from '../mocha-utils.js'; describe('Prerender', function () { setupTestBrowserHooks(); diff --git a/tools/mocha-runner/src/mocha-runner.ts b/tools/mocha-runner/src/mocha-runner.ts index a359ef81..18cd7b85 100644 --- a/tools/mocha-runner/src/mocha-runner.ts +++ b/tools/mocha-runner/src/mocha-runner.ts @@ -79,6 +79,7 @@ function getApplicableTestSuites( async function main() { const noCoverage = process.argv.indexOf('--no-coverage') !== -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'); let statsFilename = ''; @@ -192,10 +193,14 @@ async function main() { if (process.argv.indexOf('--fullTrace')) { args.push('--full-trace'); } + + 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); + }); if (shard) { - const specs = globSync('test/build/**/*.spec.js').sort((a, b) => { - return a.localeCompare(b); - }); // Shard ID is 1-based. const [shardId, shards] = shard.split('/').map(s => { return Number(s); @@ -214,17 +219,14 @@ async function main() { args.length - argsLength } files out of ${specs.length}.` ); + } else { + args.push(...specs); } const spawnArgs: SpawnOptions = { shell: true, cwd: process.cwd(), stdio: 'inherit', - env: shard - ? { - ...env, - PUPPETEER_SHARD: 'true', - } - : env, + env, }; const handle = noCoverage ? spawn('npx', ['mocha', ...args], spawnArgs)