Skip to content

Commit

Permalink
test: move cdp only tests to a subfolder (#11033)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com>
  • Loading branch information
OrKoN and Lightning00Blade committed Sep 26, 2023
1 parent 8993def commit e0e7e3a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
5 changes: 0 additions & 5 deletions .mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
: {}),
};
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions test/src/bfcache.spec.ts → test/src/cdp/bfcache.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 11 additions & 9 deletions tools/mocha-runner/src/mocha-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit e0e7e3a

Please sign in to comment.