Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: group test runner files by process (#20425)
Pavel Feldman7d7e66f450d0
diff --git a/packages/playwright-test/bundles/babel/package.json b/packages/playwright-test/bundles/babel/package.jsonindex 3a1f02051c..224ddb499a 100644--- a/packages/playwright-test/bundles/babel/package.json+++ b/packages/playwright-test/bundles/babel/package.json@@ -3,7 +3,7 @@"version": "0.0.1","private": true,"scripts": {- "esbuild": "esbuild ./src/babelBundleImpl.ts --bundle --outdir=../../lib --format=cjs --platform=node --target=ES2019",+ "esbuild": "esbuild ./src/babelBundleImpl.ts --bundle --outdir=../../lib/common --format=cjs --platform=node --target=ES2019","build": "npm run esbuild -- --minify","watch": "npm run esbuild -- --watch --sourcemap","generate-license": "node ../../../../utils/generate_third_party_notice.js"diff --git a/packages/playwright-test/bundles/expect/package.json b/packages/playwright-test/bundles/expect/package.jsonindex ea0bc37a76..258bfc68d6 100644--- a/packages/playwright-test/bundles/expect/package.json+++ b/packages/playwright-test/bundles/expect/package.json@@ -3,7 +3,7 @@"version": "0.0.1","private": true,"scripts": {- "esbuild": "esbuild ./src/expectBundleImpl.ts --bundle --outdir=../../lib --format=cjs --platform=node --target=ES2019",+ "esbuild": "esbuild ./src/expectBundleImpl.ts --bundle --outdir=../../lib/common --format=cjs --platform=node --target=ES2019","build": "npm run esbuild -- --minify","watch": "npm run esbuild -- --watch --sourcemap","generate-license": "node ../../../../utils/generate_third_party_notice.js"diff --git a/packages/playwright-test/src/DEPS.list b/packages/playwright-test/src/DEPS.listindex f0cea0df46..08d491f52e 100644--- a/packages/playwright-test/src/DEPS.list+++ b/packages/playwright-test/src/DEPS.list@@ -1,8 +1,7 @@[*]-../types.ts+common/+./utils.ts./utilsBundle.ts-runner/-matchers/-reporters/-third_party/-plugins/++[cli.ts]+**diff --git a/packages/playwright-test/src/babelBundle.ts b/packages/playwright-test/src/babelBundle.tsdeleted file mode 100644index 24105f99c1..0000000000--- a/packages/playwright-test/src/babelBundle.ts+++ /dev/null@@ -1,26 +0,0 @@-/**- * Copyright (c) Microsoft Corporation.- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--import type { BabelFileResult } from '../bundles/babel/node_modules/@types/babel__core';-export const codeFrameColumns: typeof import('../bundles/babel/node_modules/@types/babel__code-frame').codeFrameColumns = require('./babelBundleImpl').codeFrameColumns;-export const declare: typeof import('../bundles/babel/node_modules/@types/babel__helper-plugin-utils').declare = require('./babelBundleImpl').declare;-export const types: typeof import('../bundles/babel/node_modules/@types/babel__core').types = require('./babelBundleImpl').types;-export const parse: typeof import('../bundles/babel/node_modules/@babel/parser').parse = require('./babelBundleImpl').parse;-export const traverse: typeof import('../bundles/babel/node_modules/@types/babel__traverse').default = require('./babelBundleImpl').traverse;-export type BabelTransformFunction = (filename: string, isTypeScript: boolean, isModule: boolean, scriptPreprocessor: string | undefined, additionalPlugin: [string]) => BabelFileResult;-export const babelTransform: BabelTransformFunction = require('./babelBundleImpl').babelTransform;-export type { NodePath, types as T } from '../bundles/babel/node_modules/@types/babel__core';-export type { BabelAPI } from '../bundles/babel/node_modules/@types/babel__helper-plugin-utils';diff --git a/packages/playwright-test/src/cli.ts b/packages/playwright-test/src/cli.tsindex 891bf93cd5..cbd951c5e6 100644--- a/packages/playwright-test/src/cli.ts+++ b/packages/playwright-test/src/cli.ts@@ -18,18 +18,17 @@import type { Command } from 'playwright-core/lib/utilsBundle';import fs from 'fs';-import url from 'url';import path from 'path';-import { Runner } from './runner';-import type { ConfigCLIOverrides } from './runner';-import { stopProfiling, startProfiling } from './profiler';-import { fileIsModule } from './util';+import { Runner } from './runner/runner';+import { stopProfiling, startProfiling } from './common/profiler';+import { experimentalLoaderOption, fileIsModule } from './util';import type { TestFileFilter } from './util';import { createTitleMatcher } from './util';import { showHTMLReport } from './reporters/html';-import { baseFullConfig, defaultTimeout, kDefaultConfigFiles, resolveConfigFile } from './configLoader';-import type { TraceMode } from './types';+import { baseFullConfig, defaultTimeout, kDefaultConfigFiles, resolveConfigFile } from './common/configLoader';+import type { TraceMode } from './common/types';import { builtInReporters } from './runner/reporters';+import type { ConfigCLIOverrides } from './common/ipc';export function addTestCommands(program: Command) {addTestCommand(program);@@ -267,16 +266,4 @@ function restartWithExperimentalTsEsm(configFile: string | null): boolean {return true;}-export function experimentalLoaderOption() {- return ` --no-warnings --experimental-loader=${url.pathToFileURL(require.resolve('@playwright/test/lib/experimentalLoader')).toString()}`;-}--export function envWithoutExperimentalLoaderOptions(): NodeJS.ProcessEnv {- const substring = experimentalLoaderOption();- const result = { ...process.env };- if (result.NODE_OPTIONS)- result.NODE_OPTIONS = result.NODE_OPTIONS.replace(substring, '').trim() || undefined;- return result;-}-const kTraceModes: TraceMode[] = ['on', 'off', 'on-first-retry', 'retain-on-failure'];diff --git a/packages/playwright-test/src/common/DEPS.list b/packages/playwright-test/src/common/DEPS.listnew file mode 100644index 0000000000..7a1a8d340d--- /dev/null+++ b/packages/playwright-test/src/common/DEPS.list@@ -0,0 +1,11 @@+[*]+../common/+../matchers/+../util.ts+../utilsBundle.ts++[transform.ts]+../third_party/tsconfig-loader.ts++[configLoader.ts]+../runner/reporters.ts\ No newline at end of filediff --git a/packages/playwright-test/src/common/babelBundle.ts b/packages/playwright-test/src/common/babelBundle.tsnew file mode 100644index 0000000000..70f143e20d--- /dev/null+++ b/packages/playwright-test/src/common/babelBundle.ts@@ -0,0 +1,26 @@+/**+ * Copyright (c) Microsoft Corporation.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { BabelFileResult } from '../../bundles/babel/node_modules/@types/babel__core';+export const codeFrameColumns: typeof import('../../bundles/babel/node_modules/@types/babel__code-frame').codeFrameColumns = require('./babelBundleImpl').codeFrameColumns;+export const declare: typeof import('../../bundles/babel/node_modules/@types/babel__helper-plugin-utils').declare = require('./babelBundleImpl').declare;+export const types: typeof import('../../bundles/babel/node_modules/@types/babel__core').types = require('./babelBundleImpl').types;+export const parse: typeof import('../../bundles/babel/node_modules/@babel/parser/typings/babel-parser').parse = require('./babelBundleImpl').parse;+export const traverse: typeof import('../../bundles/babel/node_modules/@types/babel__traverse').default = require('./babelBundleImpl').traverse;+export type BabelTransformFunction = (filename: string, isTypeScript: boolean, isModule: boolean, scriptPreprocessor: string | undefined, additionalPlugin: [string]) => BabelFileResult;+export const babelTransform: BabelTransformFunction = require('./babelBundleImpl').babelTransform;+export type { NodePath, types as T } from '../../bundles/babel/node_modules/@types/babel__core';+export type { BabelAPI } from '../../bundles/babel/node_modules/@types/babel__helper-plugin-utils';diff --git a/packages/playwright-test/src/configLoader.ts b/packages/playwright-test/src/common/configLoader.tssimilarity index 98%rename from packages/playwright-test/src/configLoader.tsrename to packages/playwright-test/src/common/configLoader.tsindex a559aed2b7..82813f82ca 100644--- a/packages/playwright-test/src/configLoader.ts+++ b/packages/playwright-test/src/common/configLoader.ts@@ -18,13 +18,12 @@ import * as fs from 'fs';import * as os from 'os';import * as path from 'path';import { isRegExp } from 'playwright-core/lib/utils';-import type { Reporter } from '../types/testReporter';-import type { SerializedConfig } from './ipc';-import type { ConfigCLIOverrides } from './runner';-import { builtInReporters, toReporters } from './runner/reporters';+import type { Reporter } from '../../types/testReporter';+import type { ConfigCLIOverrides, SerializedConfig } from './ipc';+import { builtInReporters, toReporters } from '../runner/reporters';import { requireOrImport } from './transform';import type { Config, FullConfigInternal, FullProjectInternal, Project, ReporterDescription } from './types';-import { errorWithFile, getPackageJsonPath, mergeObjects } from './util';+import { errorWithFile, getPackageJsonPath, mergeObjects } from '../util';export const defaultTimeout = 30000;@@ -457,7 +456,7 @@ export const baseFullConfig: FullConfigInternal = {quiet: false,shard: null,updateSnapshots: 'missing',- version: require('../package.json').version,+ version: require('../../package.json').version,workers: 0,webServer: null,_webServers: [],diff --git a/packages/playwright-test/src/common/expectBundle.ts b/packages/playwright-test/src/common/expectBundle.tsnew file mode 100644index 0000000000..ad6e82453f--- /dev/null+++ b/packages/playwright-test/src/common/expectBundle.ts@@ -0,0 +1,20 @@+/**+ * Copyright (c) Microsoft Corporation.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export const expect: typeof import('../../bundles/expect/node_modules/expect/build') = require('./expectBundleImpl').expect;+export const INVERTED_COLOR: typeof import('../../bundles/expect/node_modules/jest-matcher-utils/build').INVERTED_COLOR = require('./expectBundleImpl').INVERTED_COLOR;+export const RECEIVED_COLOR: typeof import('../../bundles/expect/node_modules/jest-matcher-utils/build').RECEIVED_COLOR = require('./expectBundleImpl').RECEIVED_COLOR;+export const printReceived: typeof import('../../bundles/expect/node_modules/jest-matcher-utils/build').printReceived = require('./expectBundleImpl').printReceived;diff --git a/packages/playwright-test/src/fixtures.ts b/packages/playwright-test/src/common/fixtures.tssimilarity index 99%rename from packages/playwright-test/src/fixtures.tsrename to packages/playwright-test/src/common/fixtures.tsindex 515b580344..18437d38bb 100644--- a/packages/playwright-test/src/fixtures.ts+++ b/packages/playwright-test/src/common/fixtures.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { formatLocation, debugTest } from './util';+import { formatLocation, debugTest } from '../util';import * as crypto from 'crypto';import type { FixturesWithLocation, Location, WorkerInfo } from './types';import { ManualPromise } from 'playwright-core/lib/utils';diff --git a/packages/playwright-test/src/globals.ts b/packages/playwright-test/src/common/globals.tssimilarity index 100%rename from packages/playwright-test/src/globals.tsrename to packages/playwright-test/src/common/globals.tsdiff --git a/packages/playwright-test/src/ipc.ts b/packages/playwright-test/src/common/ipc.tssimilarity index 84%rename from packages/playwright-test/src/ipc.tsrename to packages/playwright-test/src/common/ipc.tsindex b142f9ca38..0bbef0fe77 100644--- a/packages/playwright-test/src/ipc.ts+++ b/packages/playwright-test/src/common/ipc.ts@@ -14,9 +14,27 @@* limitations under the License.*/-import type { ConfigCLIOverrides } from './runner';import type { TestInfoError, TestStatus } from './types';+export type ConfigCLIOverrides = {+ forbidOnly?: boolean;+ fullyParallel?: boolean;+ globalTimeout?: number;+ maxFailures?: number;+ outputDir?: string;+ quiet?: boolean;+ repeatEach?: number;+ retries?: number;+ reporter?: string;+ shard?: { current: number, total: number };+ timeout?: number;+ ignoreSnapshots?: boolean;+ updateSnapshots?: 'all'|'none'|'missing';+ workers?: number;+ projects?: { name: string, use?: any }[],+ use?: any;+};+export type SerializedConfig = {configFile: string | undefined;configDir: string;diff --git a/packages/playwright-test/src/poolBuilder.ts b/packages/playwright-test/src/common/poolBuilder.tssimilarity index 99%rename from packages/playwright-test/src/poolBuilder.tsrename to packages/playwright-test/src/common/poolBuilder.tsindex 796d7d4c45..d7e69f57ad 100644--- a/packages/playwright-test/src/poolBuilder.ts+++ b/packages/playwright-test/src/common/poolBuilder.ts@@ -19,7 +19,7 @@ import type { LoadError } from './fixtures';import type { Suite, TestCase } from './test';import type { TestTypeImpl } from './testType';import type { Fixtures, FixturesWithLocation, FullProjectInternal } from './types';-import { formatLocation } from './util';+import { formatLocation } from '../util';export class PoolBuilder {private _project: FullProjectInternal | undefined;diff --git a/packages/playwright-test/src/process.ts b/packages/playwright-test/src/common/process.tssimilarity index 98%rename from packages/playwright-test/src/process.tsrename to packages/playwright-test/src/common/process.tsindex 0d8f990707..c6ab3ed79d 100644--- a/packages/playwright-test/src/process.ts+++ b/packages/playwright-test/src/common/process.ts@@ -18,7 +18,7 @@ import type { WriteStream } from 'tty';import type { ProcessInitParams, TtyParams } from './ipc';import { startProfiling, stopProfiling } from './profiler';import type { TestInfoError } from './types';-import { serializeError } from './util';+import { serializeError } from '../util';export type ProtocolRequest = {id: number;diff --git a/packages/playwright-test/src/profiler.ts b/packages/playwright-test/src/common/profiler.tssimilarity index 100%rename from packages/playwright-test/src/profiler.tsrename to packages/playwright-test/src/common/profiler.tsdiff --git a/packages/playwright-test/src/suiteUtils.ts b/packages/playwright-test/src/common/suiteUtils.tssimilarity index 98%rename from packages/playwright-test/src/suiteUtils.tsrename to packages/playwright-test/src/common/suiteUtils.tsindex 2143e537d3..dd5640ef7a 100644--- a/packages/playwright-test/src/suiteUtils.ts+++ b/packages/playwright-test/src/common/suiteUtils.ts@@ -19,8 +19,8 @@ import { calculateSha1 } from 'playwright-core/lib/utils';import type { TestCase } from './test';import { Suite } from './test';import type { FullProjectInternal } from './types';-import type { Matcher } from './util';-import { createTitleMatcher } from './util';+import type { Matcher } from '../util';+import { createTitleMatcher } from '../util';export async function createRootSuite(preprocessRoot: Suite, testTitleMatcher: Matcher, filesByProject: Map<FullProjectInternal, string[]>): Promise<Suite> {// Generate projects.diff --git a/packages/playwright-test/src/test.ts b/packages/playwright-test/src/common/test.tssimilarity index 99%rename from packages/playwright-test/src/test.tsrename to packages/playwright-test/src/common/test.tsindex f5bff25012..28f4ef5a5f 100644--- a/packages/playwright-test/src/test.ts+++ b/packages/playwright-test/src/common/test.ts@@ -15,7 +15,7 @@*/import type { FixturePool } from './fixtures';-import type * as reporterTypes from '../types/testReporter';+import type * as reporterTypes from '../../types/testReporter';import type { TestTypeImpl } from './testType';import { rootTestType } from './testType';import type { Annotation, FixturesWithLocation, FullProject, FullProjectInternal, Location } from './types';diff --git a/packages/playwright-test/src/testInfo.ts b/packages/playwright-test/src/common/testInfo.tssimilarity index 98%rename from packages/playwright-test/src/testInfo.tsrename to packages/playwright-test/src/common/testInfo.tsindex 0d7ff691a7..5fb6bd9cd3 100644--- a/packages/playwright-test/src/testInfo.ts+++ b/packages/playwright-test/src/common/testInfo.ts@@ -17,12 +17,12 @@import fs from 'fs';import path from 'path';import { monotonicTime } from 'playwright-core/lib/utils';-import type { TestInfoError, TestInfo, TestStatus } from '../types/test';+import type { TestInfoError, TestInfo, TestStatus } from '../../types/test';import type { StepBeginPayload, StepEndPayload, WorkerInitParams } from './ipc';import type { TestCase } from './test';import { TimeoutManager } from './timeoutManager';import type { Annotation, FullConfigInternal, FullProjectInternal, TestStepInternal } from './types';-import { getContainedPath, normalizeAndSaveAttachment, sanitizeForFilePath, serializeError, trimLongString } from './util';+import { getContainedPath, normalizeAndSaveAttachment, sanitizeForFilePath, serializeError, trimLongString } from '../util';export class TestInfoImpl implements TestInfo {private _onStepBegin: (payload: StepBeginPayload) => void;diff --git a/packages/playwright-test/src/testLoader.ts b/packages/playwright-test/src/common/testLoader.tssimilarity index 97%rename from packages/playwright-test/src/testLoader.tsrename to packages/playwright-test/src/common/testLoader.tsindex bbd2f7da42..9324e037a5 100644--- a/packages/playwright-test/src/testLoader.ts+++ b/packages/playwright-test/src/common/testLoader.ts@@ -15,14 +15,14 @@*/import path from 'path';-import type { TestError } from '../reporter';+import type { TestError } from '../../reporter';import type { FullConfigInternal } from './types';import type { LoadError } from './fixtures';import { setCurrentlyLoadingFileSuite } from './globals';import { PoolBuilder } from './poolBuilder';import { Suite } from './test';import { requireOrImport } from './transform';-import { serializeError } from './util';+import { serializeError } from '../util';export const defaultTimeout = 30000;diff --git a/packages/playwright-test/src/testType.ts b/packages/playwright-test/src/common/testType.tssimilarity index 99%rename from packages/playwright-test/src/testType.tsrename to packages/playwright-test/src/common/testType.tsindex c13ea04813..3fe8933e63 100644--- a/packages/playwright-test/src/testType.ts+++ b/packages/playwright-test/src/common/testType.ts@@ -14,12 +14,12 @@* limitations under the License.*/-import { expect } from './expect';+import { expect } from '../matchers/expect';import { currentlyLoadingFileSuite, currentTestInfo, setCurrentlyLoadingFileSuite } from './globals';import { TestCase, Suite } from './test';import { wrapFunctionWithLocation } from './transform';import type { Fixtures, FixturesWithLocation, Location, TestType } from './types';-import { serializeError } from './util';+import { serializeError } from '../util';const testTypeSymbol = Symbol('testType');diff --git a/packages/playwright-test/src/timeoutManager.ts b/packages/playwright-test/src/common/timeoutManager.tssimilarity index 100%rename from packages/playwright-test/src/timeoutManager.tsrename to packages/playwright-test/src/common/timeoutManager.tsdiff --git a/packages/playwright-test/src/transform.ts b/packages/playwright-test/src/common/transform.tssimilarity index 97%rename from packages/playwright-test/src/transform.tsrename to packages/playwright-test/src/common/transform.tsindex 9f13ea5975..3a3ad1533f 100644--- a/packages/playwright-test/src/transform.ts+++ b/packages/playwright-test/src/common/transform.ts@@ -18,14 +18,14 @@ import crypto from 'crypto';import os from 'os';import path from 'path';import fs from 'fs';-import { sourceMapSupport, pirates } from './utilsBundle';+import { sourceMapSupport, pirates } from '../utilsBundle';import url from 'url';import type { Location } from './types';-import type { TsConfigLoaderResult } from './third_party/tsconfig-loader';-import { tsConfigLoader } from './third_party/tsconfig-loader';+import type { TsConfigLoaderResult } from '../third_party/tsconfig-loader';+import { tsConfigLoader } from '../third_party/tsconfig-loader';import Module from 'module';import type { BabelTransformFunction } from './babelBundle';-import { fileIsModule } from './util';+import { fileIsModule } from '../util';const version = 13;const cacheDir = process.env.PWTEST_CACHE_DIR || path.join(os.tmpdir(), 'playwright-transform-cache');@@ -281,8 +281,8 @@ export function wrapFunctionWithLocation<A extends any[], R>(func: (location: Lo}// This will catch the playwright-test package as well-const kPlaywrightInternalPrefix = path.resolve(__dirname, '../../playwright');-const kPlaywrightCoveragePrefix = path.resolve(__dirname, '../../../tests/config/coverage.js');+const kPlaywrightInternalPrefix = path.resolve(__dirname, '../../../playwright');+const kPlaywrightCoveragePrefix = path.resolve(__dirname, '../../../../tests/config/coverage.js');export function belongsToNodeModules(file: string) {if (file.includes(`${path.sep}node_modules${path.sep}`))diff --git a/packages/playwright-test/src/tsxTransform.ts b/packages/playwright-test/src/common/tsxTransform.tssimilarity index 100%rename from packages/playwright-test/src/tsxTransform.tsrename to packages/playwright-test/src/common/tsxTransform.tsdiff --git a/packages/playwright-test/src/types.ts b/packages/playwright-test/src/common/types.tssimilarity index 91%rename from packages/playwright-test/src/types.tsrename to packages/playwright-test/src/common/types.tsindex 1922460591..2711a6ea3d 100644--- a/packages/playwright-test/src/types.ts+++ b/packages/playwright-test/src/common/types.ts@@ -14,11 +14,11 @@* limitations under the License.*/-import type { Fixtures, TestInfoError, Project } from '../types/test';-import type { Location } from '../types/testReporter';+import type { Fixtures, TestInfoError, Project } from '../../types/test';+import type { Location } from '../../types/testReporter';import type { FullConfig as FullConfigPublic, FullProject as FullProjectPublic } from './types';-export * from '../types/test';-export type { Location } from '../types/testReporter';+export * from '../../types/test';+export type { Location } from '../../types/testReporter';export type FixturesWithLocation = {fixtures: Fixtures;diff --git a/packages/playwright-test/src/expectBundle.ts b/packages/playwright-test/src/expectBundle.tsdeleted file mode 100644index fa08f696f7..0000000000--- a/packages/playwright-test/src/expectBundle.ts+++ /dev/null@@ -1,20 +0,0 @@-/**- * Copyright (c) Microsoft Corporation.- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--export const expect: typeof import('../bundles/expect/node_modules/expect') = require('./expectBundleImpl').expect;-export const INVERTED_COLOR: typeof import('../bundles/expect/node_modules/jest-matcher-utils').INVERTED_COLOR = require('./expectBundleImpl').INVERTED_COLOR;-export const RECEIVED_COLOR: typeof import('../bundles/expect/node_modules/jest-matcher-utils').RECEIVED_COLOR = require('./expectBundleImpl').RECEIVED_COLOR;-export const printReceived: typeof import('../bundles/expect/node_modules/jest-matcher-utils').printReceived = require('./expectBundleImpl').printReceived;diff --git a/packages/playwright-test/src/experimentalLoader.ts b/packages/playwright-test/src/experimentalLoader.tsindex 67c18f0631..6e56f555de 100644--- a/packages/playwright-test/src/experimentalLoader.ts+++ b/packages/playwright-test/src/experimentalLoader.ts@@ -16,7 +16,7 @@import fs from 'fs';import url from 'url';-import { transformHook, resolveHook, belongsToNodeModules } from './transform';+import { transformHook, resolveHook, belongsToNodeModules } from './common/transform';// Node < 18.6: defaultResolve takes 3 arguments.// Node >= 18.6: nextResolve from the chain takes 2 arguments.diff --git a/packages/playwright-test/src/index.ts b/packages/playwright-test/src/index.tsindex 59acb96bdc..9a4697c47f 100644--- a/packages/playwright-test/src/index.ts+++ b/packages/playwright-test/src/index.ts@@ -20,10 +20,10 @@ import type { APIRequestContext, BrowserContext, BrowserContextOptions, LaunchOpimport * as playwrightLibrary from 'playwright-core';import { createGuid, debugMode, removeFolders, addStackIgnoreFilter } from 'playwright-core/lib/utils';import type { Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, ScreenshotMode, TestInfo, TestType, TraceMode, VideoMode } from '../types/test';-import type { TestInfoImpl } from './testInfo';-import { rootTestType } from './testType';-import { type ContextReuseMode } from './types';-export { expect } from './expect';+import type { TestInfoImpl } from './common/testInfo';+import { rootTestType } from './common/testType';+import { type ContextReuseMode } from './common/types';+export { expect } from './matchers/expect';export { addRunnerPlugin as _addRunnerPlugin } from './plugins';export const _baseTest: TestType<{}, {}> = rootTestType.test;diff --git a/packages/playwright-test/src/loader/DEPS.list b/packages/playwright-test/src/loader/DEPS.listnew file mode 100644index 0000000000..c0a39450ff--- /dev/null+++ b/packages/playwright-test/src/loader/DEPS.list@@ -0,0 +1,2 @@+[*]+../common/diff --git a/packages/playwright-test/src/loaderMain.ts b/packages/playwright-test/src/loader/loaderMain.tssimilarity index 84%rename from packages/playwright-test/src/loaderMain.tsrename to packages/playwright-test/src/loader/loaderMain.tsindex c8ab12d544..844578c8b7 100644--- a/packages/playwright-test/src/loaderMain.ts+++ b/packages/playwright-test/src/loader/loaderMain.ts@@ -14,11 +14,11 @@* limitations under the License.*/-import type { SerializedConfig } from './ipc';-import { ConfigLoader } from './configLoader';-import { ProcessRunner } from './process';-import { loadTestFilesInProcess } from './testLoader';-import type { LoadError } from './fixtures';+import type { SerializedConfig } from '../common/ipc';+import { ConfigLoader } from '../common/configLoader';+import { ProcessRunner } from '../common/process';+import { loadTestFilesInProcess } from '../common/testLoader';+import type { LoadError } from '../common/fixtures';export class LoaderMain extends ProcessRunner {private _config: SerializedConfig;diff --git a/packages/playwright-test/src/matchers/DEPS.list b/packages/playwright-test/src/matchers/DEPS.listindex 7c550a05f3..78d2f051e8 100644--- a/packages/playwright-test/src/matchers/DEPS.list+++ b/packages/playwright-test/src/matchers/DEPS.list@@ -1,4 +1,5 @@[*]+../common/../expect.ts../globals.ts../testInfo.tsdiff --git a/packages/playwright-test/src/expect.ts b/packages/playwright-test/src/matchers/expect.tssimilarity index 97%rename from packages/playwright-test/src/expect.tsrename to packages/playwright-test/src/matchers/expect.tsindex efa2e291d5..070fe5217c 100644--- a/packages/playwright-test/src/expect.ts+++ b/packages/playwright-test/src/matchers/expect.ts@@ -39,17 +39,17 @@ import {toHaveValue,toHaveValues,toPass-} from './matchers/matchers';-import { toMatchSnapshot, toHaveScreenshot } from './matchers/toMatchSnapshot';-import type { Expect } from './types';-import { currentTestInfo } from './globals';-import { serializeError, captureStackTrace, currentExpectTimeout } from './util';+} from './matchers';+import { toMatchSnapshot, toHaveScreenshot } from './toMatchSnapshot';+import type { Expect } from '../common/types';+import { currentTestInfo } from '../common/globals';+import { serializeError, captureStackTrace, currentExpectTimeout } from '../util';import {expect as expectLibrary,INVERTED_COLOR,RECEIVED_COLOR,printReceived,-} from './expectBundle';+} from '../common/expectBundle';// from expect/build/typesexport type SyncExpectationResult = {diff --git a/packages/playwright-test/src/matchers/matcherHint.ts b/packages/playwright-test/src/matchers/matcherHint.tsindex 0da2be0f0d..5ab053532f 100644--- a/packages/playwright-test/src/matchers/matcherHint.ts+++ b/packages/playwright-test/src/matchers/matcherHint.ts@@ -15,7 +15,7 @@*/import { colors } from 'playwright-core/lib/utilsBundle';-import type { Expect } from '../types';+import type { Expect } from '../common/types';export function matcherHint(state: ReturnType<Expect['getState']>, matcherName: string, a: any, b: any, matcherOptions: any, timeout?: number) {const message = state.utils.matcherHint(matcherName, a, b, matcherOptions);diff --git a/packages/playwright-test/src/matchers/matchers.ts b/packages/playwright-test/src/matchers/matchers.tsindex ec13f53eae..6204dd339f 100644--- a/packages/playwright-test/src/matchers/matchers.ts+++ b/packages/playwright-test/src/matchers/matchers.ts@@ -17,7 +17,7 @@import type { Locator, Page, APIResponse } from 'playwright-core';import type { FrameExpectOptions } from 'playwright-core/lib/client/types';import { colors } from 'playwright-core/lib/utilsBundle';-import type { Expect } from '../types';+import type { Expect } from '../common/types';import { expectTypes, callLogText } from '../util';import { toBeTruthy } from './toBeTruthy';import { toEqual } from './toEqual';diff --git a/packages/playwright-test/src/matchers/toBeTruthy.ts b/packages/playwright-test/src/matchers/toBeTruthy.tsindex cb8802e879..6ba77fa6e4 100644--- a/packages/playwright-test/src/matchers/toBeTruthy.ts+++ b/packages/playwright-test/src/matchers/toBeTruthy.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { Expect } from '../types';+import type { Expect } from '../common/types';import type { ParsedStackTrace } from '../util';import { expectTypes, callLogText, currentExpectTimeout, captureStackTrace } from '../util';import { matcherHint } from './matcherHint';diff --git a/packages/playwright-test/src/matchers/toEqual.ts b/packages/playwright-test/src/matchers/toEqual.tsindex 8cf522396c..7df1fccc37 100644--- a/packages/playwright-test/src/matchers/toEqual.ts+++ b/packages/playwright-test/src/matchers/toEqual.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { Expect } from '../types';+import type { Expect } from '../common/types';import { expectTypes } from '../util';import { callLogText, currentExpectTimeout } from '../util';import type { ParsedStackTrace } from 'playwright-core/lib/utils';diff --git a/packages/playwright-test/src/matchers/toMatchSnapshot.ts b/packages/playwright-test/src/matchers/toMatchSnapshot.tsindex c8c3fb7593..53173e6592 100644--- a/packages/playwright-test/src/matchers/toMatchSnapshot.ts+++ b/packages/playwright-test/src/matchers/toMatchSnapshot.ts@@ -17,8 +17,8 @@import type { Locator, Page } from 'playwright-core';import type { Page as PageEx } from 'playwright-core/lib/client/page';import type { Locator as LocatorEx } from 'playwright-core/lib/client/locator';-import type { Expect } from '../types';-import { currentTestInfo } from '../globals';+import type { Expect } from '../common/types';+import { currentTestInfo } from '../common/globals';import type { ImageComparatorOptions, Comparator } from 'playwright-core/lib/utils';import { getComparator } from 'playwright-core/lib/utils';import type { PageScreenshotOptions } from 'playwright-core/types/types';@@ -30,8 +30,8 @@ import { colors } from 'playwright-core/lib/utilsBundle';import fs from 'fs';import path from 'path';import { mime } from 'playwright-core/lib/utilsBundle';-import type { TestInfoImpl } from '../testInfo';-import type { SyncExpectationResult } from '../expect';+import type { TestInfoImpl } from '../common/testInfo';+import type { SyncExpectationResult } from './expect';type NameOrSegments = string | string[];const snapshotNamesSymbol = Symbol('snapshotNames');diff --git a/packages/playwright-test/src/matchers/toMatchText.ts b/packages/playwright-test/src/matchers/toMatchText.tsindex 7987b92358..e0e0de879f 100644--- a/packages/playwright-test/src/matchers/toMatchText.ts+++ b/packages/playwright-test/src/matchers/toMatchText.ts@@ -17,13 +17,13 @@import type { ExpectedTextValue } from '@protocol/channels';import { isRegExp, isString } from 'playwright-core/lib/utils';-import type { Expect } from '../types';+import type { Expect } from '../common/types';import type { ParsedStackTrace } from '../util';import { expectTypes, callLogText, currentExpectTimeout, captureStackTrace } from '../util';import {printReceivedStringContainExpectedResult,printReceivedStringContainExpectedSubstring-} from '../expect';+} from './expect';import { matcherHint } from './matcherHint';export async function toMatchText(diff --git a/packages/playwright-test/src/mount.ts b/packages/playwright-test/src/mount.tsindex ec1721c583..965a347f1b 100644--- a/packages/playwright-test/src/mount.ts+++ b/packages/playwright-test/src/mount.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { Fixtures, Locator, Page, BrowserContextOptions, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, BrowserContext, ContextReuseMode } from './types';+import type { Fixtures, Locator, Page, BrowserContextOptions, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, BrowserContext, ContextReuseMode } from './common/types';import type { Component, JsxComponent, MountOptions } from '../types/component';let boundCallbacksForMount: Function[] = [];diff --git a/packages/playwright-test/src/plugins/DEPS.list b/packages/playwright-test/src/plugins/DEPS.listindex 77c0cb3cd8..5b441c9e4e 100644--- a/packages/playwright-test/src/plugins/DEPS.list+++ b/packages/playwright-test/src/plugins/DEPS.list@@ -1,2 +1,4 @@[*]-../+../common/+../util.ts+../utilsBundle.tsdiff --git a/packages/playwright-test/src/plugins/index.ts b/packages/playwright-test/src/plugins/index.tsindex 729dca87d8..072f00cbb7 100644--- a/packages/playwright-test/src/plugins/index.ts+++ b/packages/playwright-test/src/plugins/index.ts@@ -15,8 +15,8 @@*/import type { Suite, Reporter } from '../../types/testReporter';-import type { Runner } from '../runner';-import type { FullConfig } from '../types';+import type { Runner } from '../runner/runner';+import type { FullConfig } from '../common/types';export interface TestRunnerPlugin {name: string;diff --git a/packages/playwright-test/src/plugins/vitePlugin.ts b/packages/playwright-test/src/plugins/vitePlugin.tsindex ddf1b4aab6..40e46e691d 100644--- a/packages/playwright-test/src/plugins/vitePlugin.ts+++ b/packages/playwright-test/src/plugins/vitePlugin.ts@@ -19,11 +19,11 @@ import type { Suite } from '../../types/testReporter';import path from 'path';import type { InlineConfig, Plugin } from 'vite';import type { TestRunnerPlugin } from '.';-import { parse, traverse, types as t } from '../babelBundle';+import { parse, traverse, types as t } from '../common/babelBundle';import { stoppable } from '../utilsBundle';-import type { ComponentInfo } from '../tsxTransform';-import { collectComponentUsages, componentInfo } from '../tsxTransform';-import type { FullConfig } from '../types';+import type { ComponentInfo } from '../common/tsxTransform';+import { collectComponentUsages, componentInfo } from '../common/tsxTransform';+import type { FullConfig } from '../common/types';import { assert, calculateSha1 } from 'playwright-core/lib/utils';import type { AddressInfo } from 'net';import { getPlaywrightVersion } from 'playwright-core/lib/utils';diff --git a/packages/playwright-test/src/plugins/webServerPlugin.ts b/packages/playwright-test/src/plugins/webServerPlugin.tsindex b87095ffbf..85eedd2c6c 100644--- a/packages/playwright-test/src/plugins/webServerPlugin.ts+++ b/packages/playwright-test/src/plugins/webServerPlugin.ts@@ -23,8 +23,8 @@ import { raceAgainstTimeout, launchProcess } from 'playwright-core/lib/utils';import type { FullConfig, Reporter } from '../../types/testReporter';import type { TestRunnerPlugin } from '.';-import type { FullConfigInternal } from '../types';-import { envWithoutExperimentalLoaderOptions } from '../cli';+import type { FullConfigInternal } from '../common/types';+import { envWithoutExperimentalLoaderOptions } from '../util';export type WebServerPluginOptions = {diff --git a/packages/playwright-test/src/reporters/DEPS.list b/packages/playwright-test/src/reporters/DEPS.listindex 54a397388f..a936a7bf2b 100644--- a/packages/playwright-test/src/reporters/DEPS.list+++ b/packages/playwright-test/src/reporters/DEPS.list@@ -1,4 +1,5 @@[*]+../common/../babelBundle.ts../test.ts../util.tsdiff --git a/packages/playwright-test/src/reporters/base.ts b/packages/playwright-test/src/reporters/base.tsindex db58b0e7e9..975cdf59bb 100644--- a/packages/playwright-test/src/reporters/base.ts+++ b/packages/playwright-test/src/reporters/base.ts@@ -18,8 +18,8 @@ import { colors, ms as milliseconds, parseStackTraceLine } from 'playwright-coreimport fs from 'fs';import path from 'path';import type { FullConfig, TestCase, Suite, TestResult, TestError, FullResult, TestStep, Location, Reporter } from '../../types/testReporter';-import type { FullConfigInternal } from '../types';-import { codeFrameColumns } from '../babelBundle';+import type { FullConfigInternal } from '../common/types';+import { codeFrameColumns } from '../common/babelBundle';import { monotonicTime } from 'playwright-core/lib/utils';export type TestResultOutput = { chunk: string | Buffer, type: 'stdout' | 'stderr' };diff --git a/packages/playwright-test/src/reporters/html.ts b/packages/playwright-test/src/reporters/html.tsindex 4672e78a26..b9329d0888 100644--- a/packages/playwright-test/src/reporters/html.ts+++ b/packages/playwright-test/src/reporters/html.ts@@ -26,7 +26,7 @@ import type { JsonAttachment, JsonReport, JsonSuite, JsonTestCase, JsonTestResulimport RawReporter from './raw';import { stripAnsiEscapes } from './base';import { getPackageJsonPath, sanitizeForFilePath } from '../util';-import type { FullConfigInternal, Metadata } from '../types';+import type { FullConfigInternal, Metadata } from '../common/types';import type { ZipFile } from 'playwright-core/lib/zipBundle';import { yazl } from 'playwright-core/lib/zipBundle';import { mime } from 'playwright-core/lib/utilsBundle';diff --git a/packages/playwright-test/src/reporters/multiplexer.ts b/packages/playwright-test/src/reporters/multiplexer.tsindex ab6877719f..8a3a37053d 100644--- a/packages/playwright-test/src/reporters/multiplexer.ts+++ b/packages/playwright-test/src/reporters/multiplexer.ts@@ -15,7 +15,7 @@*/import type { FullConfig, TestCase, TestError, TestResult, FullResult, TestStep, Reporter } from '../../types/testReporter';-import { Suite } from '../test';+import { Suite } from '../common/test';type StdIOChunk = {type: 'stdout' | 'stderr';diff --git a/packages/playwright-test/src/reporters/raw.ts b/packages/playwright-test/src/reporters/raw.tsindex 7ecbd193db..d9c1baa2e6 100644--- a/packages/playwright-test/src/reporters/raw.ts+++ b/packages/playwright-test/src/reporters/raw.ts@@ -22,8 +22,8 @@ import { sanitizeForFilePath } from '../util';import { formatResultFailure } from './base';import { toPosixPath, serializePatterns } from './json';import { MultiMap } from 'playwright-core/lib/utils';-import { codeFrameColumns } from '../babelBundle';-import type { Metadata } from '../types';+import { codeFrameColumns } from '../common/babelBundle';+import type { Metadata } from '../common/types';export type JsonLocation = Location;export type JsonError = string;diff --git a/packages/playwright-test/src/runner/DEPS.list b/packages/playwright-test/src/runner/DEPS.listindex 16e416eee5..e4b32ae307 100644--- a/packages/playwright-test/src/runner/DEPS.list+++ b/packages/playwright-test/src/runner/DEPS.list@@ -1,7 +1,8 @@[*]-../../../types.ts+../common/../matchers/../reporters/../third_party/../plugins/+../util.ts\ No newline at end of filediff --git a/packages/playwright-test/src/dispatcher.ts b/packages/playwright-test/src/runner/dispatcher.tssimilarity index 98%rename from packages/playwright-test/src/dispatcher.tsrename to packages/playwright-test/src/runner/dispatcher.tsindex b7bb018fce..c3a759b23c 100644--- a/packages/playwright-test/src/dispatcher.ts+++ b/packages/playwright-test/src/runner/dispatcher.ts@@ -14,15 +14,15 @@* limitations under the License.*/-import type { TestBeginPayload, TestEndPayload, DonePayload, TestOutputPayload, StepBeginPayload, StepEndPayload, TeardownErrorsPayload, RunPayload, SerializedConfig } from './ipc';-import type { TestResult, Reporter, TestStep, TestError } from '../types/testReporter';-import type { Suite } from './test';-import type { ConfigLoader } from './configLoader';+import type { TestBeginPayload, TestEndPayload, DonePayload, TestOutputPayload, StepBeginPayload, StepEndPayload, TeardownErrorsPayload, RunPayload, SerializedConfig } from '../common/ipc';+import type { TestResult, Reporter, TestStep, TestError } from '../../types/testReporter';+import type { Suite } from '../common/test';+import type { ConfigLoader } from '../common/configLoader';import type { ProcessExitData } from './processHost';-import type { TestCase } from './test';+import type { TestCase } from '../common/test';import { ManualPromise } from 'playwright-core/lib/utils';import { WorkerHost } from './workerHost';-import type { TestGroup } from './runner/testGroups';+import type { TestGroup } from './testGroups';type TestResultData = {result: TestResult;diff --git a/packages/playwright-test/src/runner/loadUtils.ts b/packages/playwright-test/src/runner/loadUtils.tsindex c069d5fbd1..e1cbedb454 100644--- a/packages/playwright-test/src/runner/loadUtils.ts+++ b/packages/playwright-test/src/runner/loadUtils.ts@@ -16,14 +16,14 @@import path from 'path';import type { TestError } from '../../types/testReporter';-import type { ConfigLoader } from '../configLoader';-import type { LoadError } from '../fixtures';-import { LoaderHost } from '../loaderHost';+import type { ConfigLoader } from '../common/configLoader';+import type { LoadError } from '../common/fixtures';+import { LoaderHost } from './loaderHost';import type { Multiplexer } from '../reporters/multiplexer';-import { createRootSuite, filterOnly, filterSuite } from '../suiteUtils';-import type { Suite, TestCase } from '../test';-import { loadTestFilesInProcess } from '../testLoader';-import type { FullConfigInternal } from '../types';+import { createRootSuite, filterOnly, filterSuite } from '../common/suiteUtils';+import type { Suite, TestCase } from '../common/test';+import { loadTestFilesInProcess } from '../common/testLoader';+import type { FullConfigInternal } from '../common/types';import type { Matcher, TestFileFilter } from '../util';import { createFileMatcher } from '../util';import { collectFilesForProjects, collectProjects } from './projectUtils';diff --git a/packages/playwright-test/src/loaderHost.ts b/packages/playwright-test/src/runner/loaderHost.tssimilarity index 84%rename from packages/playwright-test/src/loaderHost.tsrename to packages/playwright-test/src/runner/loaderHost.tsindex 0300697b1a..f3e4c4252f 100644--- a/packages/playwright-test/src/loaderHost.ts+++ b/packages/playwright-test/src/runner/loaderHost.ts@@ -14,14 +14,14 @@* limitations under the License.*/-import type { Reporter, TestError } from '../reporter';-import type { SerializedConfig } from './ipc';+import type { Reporter, TestError } from '../../reporter';+import type { SerializedConfig } from '../common/ipc';import { ProcessHost } from './processHost';-import { Suite } from './test';+import { Suite } from '../common/test';export class LoaderHost extends ProcessHost {constructor() {- super(require.resolve('./loaderMain.js'), 'loader');+ super(require.resolve('../loaderMain.js'), 'loader');}async start(config: SerializedConfig) {diff --git a/packages/playwright-test/src/processHost.ts b/packages/playwright-test/src/runner/processHost.tssimilarity index 96%rename from packages/playwright-test/src/processHost.tsrename to packages/playwright-test/src/runner/processHost.tsindex 92678f8ad0..530b7625da 100644--- a/packages/playwright-test/src/processHost.ts+++ b/packages/playwright-test/src/runner/processHost.ts@@ -17,8 +17,8 @@import child_process from 'child_process';import { EventEmitter } from 'events';import { debug } from 'playwright-core/lib/utilsBundle';-import type { ProcessInitParams } from './ipc';-import type { ProtocolResponse } from './process';+import type { ProcessInitParams } from '../common/ipc';+import type { ProtocolResponse } from '../common/process';export type ProcessExitData = {unexpectedly: boolean;@@ -43,7 +43,7 @@ export class ProcessHost extends EventEmitter {}protected async startRunner(runnerParams: any, inheritStdio: boolean, env: NodeJS.ProcessEnv) {- this.process = child_process.fork(require.resolve('./process'), {+ this.process = child_process.fork(require.resolve('../common/process'), {detached: false,env: { ...process.env, ...env },stdio: inheritStdio ? ['ignore', 'inherit', 'inherit', 'ipc'] : ['ignore', 'ignore', process.env.PW_RUNNER_DEBUG ? 'inherit' : 'ignore', 'ipc'],diff --git a/packages/playwright-test/src/runner/projectUtils.ts b/packages/playwright-test/src/runner/projectUtils.tsindex 171c5c1597..c24fd52b77 100644--- a/packages/playwright-test/src/runner/projectUtils.ts+++ b/packages/playwright-test/src/runner/projectUtils.ts@@ -18,7 +18,7 @@ import fs from 'fs';import path from 'path';import { minimatch } from 'playwright-core/lib/utilsBundle';import { promisify } from 'util';-import type { FullConfigInternal, FullProjectInternal } from '../types';+import type { FullConfigInternal, FullProjectInternal } from '../common/types';import type { TestFileFilter } from '../util';import { createFileMatcher, createFileMatcherFromFilters } from '../util';diff --git a/packages/playwright-test/src/runner/reporters.ts b/packages/playwright-test/src/runner/reporters.tsindex 09d63109d4..dc1e4bfb18 100644--- a/packages/playwright-test/src/runner/reporters.ts+++ b/packages/playwright-test/src/runner/reporters.ts@@ -16,7 +16,7 @@import path from 'path';import type { Reporter, TestError } from '../../types/testReporter';-import type { ConfigLoader } from '../configLoader';+import type { ConfigLoader } from '../common/configLoader';import { formatError } from '../reporters/base';import DotReporter from '../reporters/dot';import EmptyReporter from '../reporters/empty';@@ -27,8 +27,8 @@ import JUnitReporter from '../reporters/junit';import LineReporter from '../reporters/line';import ListReporter from '../reporters/list';import { Multiplexer } from '../reporters/multiplexer';-import type { Suite } from '../test';-import type { FullConfigInternal, ReporterDescription } from '../types';+import type { Suite } from '../common/test';+import type { FullConfigInternal, ReporterDescription } from '../common/types';export async function createReporter(configLoader: ConfigLoader, list: boolean) {const defaultReporters: {[key in BuiltInReporter]: new(arg: any) => Reporter} = {diff --git a/packages/playwright-test/src/runner.ts b/packages/playwright-test/src/runner/runner.tssimilarity index 78%rename from packages/playwright-test/src/runner.tsrename to packages/playwright-test/src/runner/runner.tsindex 1925affe00..40bc913cce 100644--- a/packages/playwright-test/src/runner.ts+++ b/packages/playwright-test/src/runner/runner.ts@@ -16,37 +16,19 @@*/import { monotonicTime } from 'playwright-core/lib/utils';-import type { FullResult } from '../types/testReporter';-import { ConfigLoader } from './configLoader';-import type { TestRunnerPlugin } from './plugins';-import { setRunnerToAddPluginsTo } from './plugins';-import { dockerPlugin } from './plugins/dockerPlugin';-import { webServerPluginsForConfig } from './plugins/webServerPlugin';-import { collectFilesForProjects, collectProjects } from './runner/projectUtils';-import { createReporter } from './runner/reporters';-import { createTaskRunner } from './runner/tasks';-import type { TaskRunnerState } from './runner/tasks';-import type { Config, FullConfigInternal } from './types';-import type { Matcher, TestFileFilter } from './util';--export type ConfigCLIOverrides = {- forbidOnly?: boolean;- fullyParallel?: boolean;- globalTimeout?: number;- maxFailures?: number;- outputDir?: string;- quiet?: boolean;- repeatEach?: number;- retries?: number;- reporter?: string;- shard?: { current: number, total: number };- timeout?: number;- ignoreSnapshots?: boolean;- updateSnapshots?: 'all'|'none'|'missing';- workers?: number;- projects?: { name: string, use?: any }[],- use?: any;-};+import type { FullResult } from '../../types/testReporter';+import { ConfigLoader } from '../common/configLoader';+import type { TestRunnerPlugin } from '../plugins';+import { setRunnerToAddPluginsTo } from '../plugins';+import { dockerPlugin } from '../plugins/dockerPlugin';+import { webServerPluginsForConfig } from '../plugins/webServerPlugin';+import { collectFilesForProjects, collectProjects } from './projectUtils';+import { createReporter } from './reporters';+import { createTaskRunner } from './tasks';+import type { TaskRunnerState } from './tasks';+import type { Config, FullConfigInternal } from '../common/types';+import type { Matcher, TestFileFilter } from '../util';+import type { ConfigCLIOverrides } from '../common/ipc';export type RunOptions = {listOnly: boolean;diff --git a/packages/playwright-test/src/sigIntWatcher.ts b/packages/playwright-test/src/runner/sigIntWatcher.tssimilarity index 100%rename from packages/playwright-test/src/sigIntWatcher.tsrename to packages/playwright-test/src/runner/sigIntWatcher.tsdiff --git a/packages/playwright-test/src/taskRunner.ts b/packages/playwright-test/src/runner/taskRunner.tssimilarity index 97%rename from packages/playwright-test/src/taskRunner.tsrename to packages/playwright-test/src/runner/taskRunner.tsindex 8e3acec20e..cca8813c50 100644--- a/packages/playwright-test/src/taskRunner.ts+++ b/packages/playwright-test/src/runner/taskRunner.ts@@ -16,9 +16,9 @@import { debug } from 'playwright-core/lib/utilsBundle';import { ManualPromise, monotonicTime } from 'playwright-core/lib/utils';-import type { FullResult, Reporter, TestError } from '../reporter';+import type { FullResult, Reporter, TestError } from '../../reporter';import { SigIntWatcher } from './sigIntWatcher';-import { serializeError } from './util';+import { serializeError } from '../util';type TaskTeardown = () => Promise<any> | undefined;export type Task<Context> = (context: Context, errors: TestError[]) => Promise<TaskTeardown | void> | undefined;diff --git a/packages/playwright-test/src/runner/tasks.ts b/packages/playwright-test/src/runner/tasks.tsindex 433cc97722..56e2a1ff30 100644--- a/packages/playwright-test/src/runner/tasks.ts+++ b/packages/playwright-test/src/runner/tasks.ts@@ -18,16 +18,16 @@ import fs from 'fs';import path from 'path';import { promisify } from 'util';import { colors, rimraf } from 'playwright-core/lib/utilsBundle';-import type { ConfigLoader } from '../configLoader';-import { Dispatcher } from '../dispatcher';+import type { ConfigLoader } from '../common/configLoader';+import { Dispatcher } from './dispatcher';import type { TestRunnerPlugin } from '../plugins';import type { Multiplexer } from '../reporters/multiplexer';import type { TestGroup } from '../runner/testGroups';import { createTestGroups, filterForShard } from '../runner/testGroups';-import type { Task } from '../taskRunner';-import { TaskRunner } from '../taskRunner';-import type { Suite } from '../test';-import type { FullConfigInternal } from '../types';+import type { Task } from './taskRunner';+import { TaskRunner } from './taskRunner';+import type { Suite } from '../common/test';+import type { FullConfigInternal } from '../common/types';import { loadAllTests } from './loadUtils';import type { Matcher, TestFileFilter } from '../util';diff --git a/packages/playwright-test/src/runner/testGroups.ts b/packages/playwright-test/src/runner/testGroups.tsindex 8bd7366bc9..efa2e0d781 100644--- a/packages/playwright-test/src/runner/testGroups.ts+++ b/packages/playwright-test/src/runner/testGroups.ts@@ -14,8 +14,8 @@* limitations under the License.*/-import { filterSuiteWithOnlySemantics } from '../suiteUtils';-import type { Suite, TestCase } from '../test';+import { filterSuiteWithOnlySemantics } from '../common/suiteUtils';+import type { Suite, TestCase } from '../common/test';export type TestGroup = {workerHash: string;diff --git a/packages/playwright-test/src/workerHost.ts b/packages/playwright-test/src/runner/workerHost.tssimilarity index 92%rename from packages/playwright-test/src/workerHost.tsrename to packages/playwright-test/src/runner/workerHost.tsindex e5f1385b14..96eeaa4c6d 100644--- a/packages/playwright-test/src/workerHost.ts+++ b/packages/playwright-test/src/runner/workerHost.ts@@ -14,8 +14,8 @@* limitations under the License.*/-import type { TestGroup } from './runner/testGroups';-import type { RunPayload, SerializedConfig, WorkerInitParams } from './ipc';+import type { TestGroup } from './testGroups';+import type { RunPayload, SerializedConfig, WorkerInitParams } from '../common/ipc';import { ProcessHost } from './processHost';let lastWorkerIndex = 0;@@ -29,7 +29,7 @@ export class WorkerHost extends ProcessHost {constructor(testGroup: TestGroup, parallelIndex: number, config: SerializedConfig) {const workerIndex = lastWorkerIndex++;- super(require.resolve('./workerMain.js'), `worker-${workerIndex}`);+ super(require.resolve('../worker/workerMain.js'), `worker-${workerIndex}`);this.workerIndex = workerIndex;this.parallelIndex = parallelIndex;this._hash = testGroup.workerHash;diff --git a/packages/playwright-test/src/util.ts b/packages/playwright-test/src/util.tsindex 720e58f2fd..920fac627a 100644--- a/packages/playwright-test/src/util.ts+++ b/packages/playwright-test/src/util.ts@@ -20,18 +20,18 @@ import util from 'util';import path from 'path';import url from 'url';import { colors, debug, minimatch } from 'playwright-core/lib/utilsBundle';-import type { TestInfoError, Location } from './types';+import type { TestInfoError, Location } from './common/types';import { calculateSha1, isRegExp, isString, captureStackTrace as coreCaptureStackTrace } from 'playwright-core/lib/utils';import { isInternalFileName } from 'playwright-core/lib/utils';-import { currentTestInfo } from './globals';+import { currentTestInfo } from './common/globals';import type { ParsedStackTrace } from 'playwright-core/lib/utils';export type { ParsedStackTrace };const PLAYWRIGHT_CORE_PATH = path.dirname(require.resolve('playwright-core'));-const EXPECT_PATH = require.resolve('./expectBundle');-const EXPECT_PATH_IMPL = require.resolve('./expectBundleImpl');-const PLAYWRIGHT_TEST_PATH = path.join(__dirname, '..');+const EXPECT_PATH = require.resolve('./common/expectBundle');+const EXPECT_PATH_IMPL = require.resolve('./common/expectBundleImpl');+const PLAYWRIGHT_TEST_PATH = path.join(__dirname, '../..');function filterStackTrace(e: Error) {if (process.env.PWDEBUGIMPL)@@ -313,3 +313,15 @@ export function folderIsModule(folder: string): boolean {// Rely on `require` internal caching logic.return require(packageJsonPath).type === 'module';}++export function experimentalLoaderOption() {+ return ` --no-warnings --experimental-loader=${url.pathToFileURL(require.resolve('@playwright/test/lib/experimentalLoader')).toString()}`;+}++export function envWithoutExperimentalLoaderOptions(): NodeJS.ProcessEnv {+ const substring = experimentalLoaderOption();+ const result = { ...process.env };+ if (result.NODE_OPTIONS)+ result.NODE_OPTIONS = result.NODE_OPTIONS.replace(substring, '').trim() || undefined;+ return result;+}diff --git a/packages/playwright-test/src/utilsBundle.ts b/packages/playwright-test/src/utilsBundle.tsindex 4e8ecf3909..d67e070a62 100644--- a/packages/playwright-test/src/utilsBundle.ts+++ b/packages/playwright-test/src/utilsBundle.ts@@ -14,7 +14,7 @@* limitations under the License.*/-export const json5: typeof import('../bundles/utils/node_modules/json5') = require('./utilsBundleImpl').json5;+export const json5: typeof import('../bundles/utils/node_modules/json5/lib') = require('./utilsBundleImpl').json5;export const open: typeof import('../bundles/utils/node_modules/open') = require('./utilsBundleImpl').open;export const pirates: typeof import('../bundles/utils/node_modules/pirates') = require('./utilsBundleImpl').pirates;export const sourceMapSupport: typeof import('../bundles/utils/node_modules/@types/source-map-support') = require('./utilsBundleImpl').sourceMapSupport;diff --git a/packages/playwright-test/src/worker/DEPS.list b/packages/playwright-test/src/worker/DEPS.listnew file mode 100644index 0000000000..bfce245fbb--- /dev/null+++ b/packages/playwright-test/src/worker/DEPS.list@@ -0,0 +1,4 @@+[*]+../common/+../util.ts+../utilBundle.tsdiff --git a/packages/playwright-test/src/workerMain.ts b/packages/playwright-test/src/worker/workerMain.tssimilarity index 97%rename from packages/playwright-test/src/workerMain.tsrename to packages/playwright-test/src/worker/workerMain.tsindex 731b1d6883..63bdd945f5 100644--- a/packages/playwright-test/src/workerMain.ts+++ b/packages/playwright-test/src/worker/workerMain.ts@@ -16,21 +16,21 @@import { colors, rimraf } from 'playwright-core/lib/utilsBundle';import util from 'util';-import { debugTest, formatLocation, relativeFilePath, serializeError } from './util';-import type { TestBeginPayload, TestEndPayload, RunPayload, DonePayload, WorkerInitParams, TeardownErrorsPayload, TestOutputPayload } from './ipc';-import { setCurrentTestInfo } from './globals';-import { ConfigLoader } from './configLoader';-import type { Suite, TestCase } from './test';-import type { Annotation, FullProjectInternal, TestInfoError } from './types';-import { FixtureRunner } from './fixtures';+import { debugTest, formatLocation, relativeFilePath, serializeError } from '../util';+import type { TestBeginPayload, TestEndPayload, RunPayload, DonePayload, WorkerInitParams, TeardownErrorsPayload, TestOutputPayload } from '../common/ipc';+import { setCurrentTestInfo } from '../common/globals';+import { ConfigLoader } from '../common/configLoader';+import type { Suite, TestCase } from '../common/test';+import type { Annotation, FullProjectInternal, TestInfoError } from '../common/types';+import { FixtureRunner } from '../common/fixtures';import { ManualPromise } from 'playwright-core/lib/utils';-import { TestInfoImpl } from './testInfo';-import type { TimeSlot } from './timeoutManager';-import { TimeoutManager } from './timeoutManager';-import { ProcessRunner } from './process';-import { TestLoader } from './testLoader';-import { buildFileSuiteForProject, filterTestsRemoveEmptySuites } from './suiteUtils';-import { PoolBuilder } from './poolBuilder';+import { TestInfoImpl } from '../common/testInfo';+import type { TimeSlot } from '../common/timeoutManager';+import { TimeoutManager } from '../common/timeoutManager';+import { ProcessRunner } from '../common/process';+import { TestLoader } from '../common/testLoader';+import { buildFileSuiteForProject, filterTestsRemoveEmptySuites } from '../common/suiteUtils';+import { PoolBuilder } from '../common/poolBuilder';const removeFolderAsync = util.promisify(rimraf);