Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(test runner): run tests under bun, add parse error locations (#43402)

Pavel Feldmand96199f58b23
diff --git a/packages/playwright/src/common/testLoader.ts b/packages/playwright/src/common/testLoader.ts
index 6e982cb220..c525f37873 100644
--- a/packages/playwright/src/common/testLoader.ts
+++ b/packages/playwright/src/common/testLoader.ts
@@ -15,14 +15,13 @@
*/
import path from 'path';
-import util from 'util';
import { isWorkerProcess, setCurrentlyLoadingFileSuite } from '../globals';
import { Suite } from './test';
import { requireOrImport, startCollectingFileDeps, stopCollectingFileDeps } from '../transform/transform';
-import { filterStackTrace } from '../util';
+import { serializeError } from '../util';
-import type { TestError } from '../../types/testReporter';
+import type { Location, TestError } from '../../types/testReporter';
import type { FullConfigInternal } from './config';
export const defaultTimeout = 30000;
@@ -48,7 +47,7 @@ export async function loadTestFile(file: string, config: FullConfigInternal, tes
} catch (e) {
if (!testErrors)
throw e;
- testErrors.push(serializeLoadError(file, e));
+ testErrors.push(...serializeLoadErrors(e));
} finally {
setCurrentlyLoadingFileSuite(undefined);
if (!isWorkerProcess())
@@ -78,17 +77,19 @@ export async function loadTestFile(file: string, config: FullConfigInternal, tes
return suite;
}
-function serializeLoadError(file: string, error: Error | any): TestError {
- if (error instanceof Error) {
- const result: TestError = filterStackTrace(error);
- // Babel parse errors have location.
- const loc = (error as any).loc;
- result.location = loc ? {
- file,
- line: loc.line || 0,
- column: loc.column || 0,
- } : undefined;
- return result;
- }
- return { value: util.inspect(error) };
+function serializeLoadErrors(error: Error | any): TestError[] {
+ if (error instanceof AggregateError)
+ return error.errors.flatMap(serializeLoadErrors);
+ const result: TestError = serializeError(error);
+ if (error instanceof Error)
+ result.location = parseErrorLocation(error);
+ return [result];
+}
+
+// Transform syntax errors have loc, bun parse errors have position.
+type ParseError = Error & { loc?: Location, position?: Location };
+
+function parseErrorLocation(error: ParseError): Location | undefined {
+ const location = error.loc ?? error.position;
+ return location && { file: location.file, line: location.line, column: location.column };
}
diff --git a/packages/playwright/src/runner/dispatcher.ts b/packages/playwright/src/runner/dispatcher.ts
index 4a9666184e..f8a82e883d 100644
--- a/packages/playwright/src/runner/dispatcher.ts
+++ b/packages/playwright/src/runner/dispatcher.ts
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+import { isUtf8 } from 'buffer';
+
import colors from 'colors/safe';
import { ManualPromise } from '@isomorphic/manualPromise';
import { eventsHelper } from '@utils/eventsHelper';
@@ -700,5 +702,6 @@ class JobDispatcher {
function chunkFromParams(params: ipc.TestOutputPayload): string | Buffer {
if (typeof params.text === 'string')
return params.text;
- return Buffer.from(params.buffer!, 'base64');
+ const buffer = Buffer.from(params.buffer!, 'base64');
+ return isUtf8(buffer) ? buffer.toString('utf8') : buffer;
}
diff --git a/packages/playwright/src/transform/babelBundle.ts b/packages/playwright/src/transform/babelBundle.ts
index 85ee4f1ffc..e7477d219b 100644
--- a/packages/playwright/src/transform/babelBundle.ts
+++ b/packages/playwright/src/transform/babelBundle.ts
@@ -188,11 +188,22 @@ export function babelTransform(code: string, filename: string, isModule: boolean
try {
const options = babelTransformOptions(isTypeScript(filename), isModule, pluginsEpilogue, useDefineForClassFields, jsx);
return babel.transform(code, { filename, ...options });
+ } catch (error) {
+ throw toSyntaxError(error, filename);
} finally {
isTransforming = false;
}
}
+function toSyntaxError(error: any, filename: string): Error {
+ if (!error?.loc)
+ return error;
+ // Drop babel's code frame, the reporter draws one from the location.
+ const syntaxError = new SyntaxError(error.message.split('\n\n')[0]);
+ (syntaxError as any).loc = { file: filename, line: error.loc.line, column: error.loc.column + 1 };
+ return syntaxError;
+}
+
export function babelParse(code: string, filename: string, isModule: boolean): babel.ParseResult {
const options = babelTransformOptions(isTypeScript(filename), isModule, [], true);
return babel.parse(code, { filename, ...options })!;
diff --git a/packages/playwright/src/transform/esbuildTransform.ts b/packages/playwright/src/transform/esbuildTransform.ts
index 0e26d0e000..d116d111e3 100644
--- a/packages/playwright/src/transform/esbuildTransform.ts
+++ b/packages/playwright/src/transform/esbuildTransform.ts
@@ -16,8 +16,6 @@
import path from 'path';
-import { libPath } from '../package';
-
import type * as esbuild from 'esbuild';
import type { JsxOptions } from './babelBundle';
@@ -37,7 +35,7 @@ export function esbuildTransform(esbuild: Esbuild, code: string, filename: strin
try {
result = transformSync(esbuild, code, options);
} catch (error) {
- throw toSyntaxError(error, code, filename);
+ throw toSyntaxError(error, filename);
}
return { code: result.code, map: JSON.parse(result.map) };
}
@@ -79,14 +77,12 @@ function transformSync(esbuild: Esbuild, code: string, options: esbuild.Transfor
}
}
-function toSyntaxError(error: any, code: string, filename: string): Error {
+function toSyntaxError(error: any, filename: string): Error {
const message: esbuild.Message | undefined = error?.errors?.[0];
if (!message?.location)
return error;
const { line, column } = message.location;
- const { codeFrameColumns } = require(libPath('transform', 'babelBundle'));
- const codeFrame = codeFrameColumns(code, { start: { line, column: column + 1 } });
- const syntaxError = new SyntaxError(`${filename}: ${message.text} (${line}:${column})\n\n${codeFrame}`);
- (syntaxError as any).loc = { line, column };
+ const syntaxError = new SyntaxError(`${filename}: ${message.text} (${line}:${column})`);
+ (syntaxError as any).loc = { file: filename, line, column: column + 1 };
return syntaxError;
}
diff --git a/packages/playwright/src/transform/transform.ts b/packages/playwright/src/transform/transform.ts
index 816c654fd7..e3f6ef9144 100644
--- a/packages/playwright/src/transform/transform.ts
+++ b/packages/playwright/src/transform/transform.ts
@@ -338,6 +338,11 @@ function installTransformIfNeeded() {
return;
transformInstalled = true;
+ // Transpilation in `bun` is not necessary, and trying to register a hook would cause issues.
+ // https://github.com/oven-sh/bun/issues/8222#issuecomment-3665364677
+ if ('Bun' in globalThis)
+ return;
+
registerESMLoader();
cc.installSourceMapSupport();
@@ -389,28 +394,44 @@ const collectCJSDependencies = (module: Module, dependencies: Set<string>) => {
export function wrapFunctionWithLocation<A extends any[], R>(func: (location: Location, ...args: A) => R): (...args: A) => R {
return (...args) => {
const oldPrepareStackTrace = Error.prepareStackTrace;
- Error.prepareStackTrace = (error, stackFrames) => {
- const frame = sourceMapSupport.wrapCallSite(stackFrames[1] as any) as NodeJS.CallSite;
- const fileName = frame.getFileName();
- // Node error stacks for modules use file:// urls instead of paths.
- const file = (fileName && fileName.startsWith('file://')) ? url.fileURLToPath(fileName) : fileName;
- return {
- file,
- line: frame.getLineNumber(),
- column: frame.getColumnNumber(),
- };
- };
const oldStackTraceLimit = Error.stackTraceLimit;
+ Error.prepareStackTrace = 'Bun' in globalThis ? bunCallerLocation : nodeCallerLocation;
Error.stackTraceLimit = 2;
const obj: { stack: Location } = {} as any;
- Error.captureStackTrace(obj);
- const location = obj.stack;
- Error.stackTraceLimit = oldStackTraceLimit;
- Error.prepareStackTrace = oldPrepareStackTrace;
+ let location: Location;
+ try {
+ Error.captureStackTrace(obj);
+ location = obj.stack;
+ } finally {
+ Error.stackTraceLimit = oldStackTraceLimit;
+ Error.prepareStackTrace = oldPrepareStackTrace;
+ }
return func(location, ...args);
};
}
+function nodeCallerLocation(error: Error, stackFrames: NodeJS.CallSite[]) {
+ const frame = sourceMapSupport.wrapCallSite(stackFrames[1] as any) as NodeJS.CallSite;
+ const fileName = frame.getFileName();
+ // Node error stacks for modules use file:// urls instead of paths.
+ const file = (fileName && fileName.startsWith('file://')) ? url.fileURLToPath(fileName) : fileName;
+ return {
+ file,
+ line: frame.getLineNumber(),
+ column: frame.getColumnNumber(),
+ };
+}
+
+function bunCallerLocation(error: Error, stackFrames: NodeJS.CallSite[]) {
+ const frame = stackFrames[1];
+ return {
+ file: frame.getFileName(),
+ line: frame.getLineNumber(),
+ // Bun's CallSite.getColumnNumber() is 0-based.
+ column: frame.getColumnNumber()! + 1,
+ };
+}
+
function isRelativeSpecifier(specifier: string) {
return specifier === '.' || specifier === '..' || specifier.startsWith('./') || specifier.startsWith('../');
}
@@ -426,11 +447,6 @@ function registerESMLoader() {
if (process.env.PW_DISABLE_TS_ESM)
return;
- // Transpilation in `bun` is not necessary, and trying to register a hook would cause issues.
- // https://github.com/oven-sh/bun/issues/8222#issuecomment-3665364677
- if ('Bun' in globalThis)
- return;
-
const nodeModule = require('node:module');
if (nodeModule.registerHooks && !process.env.PLAYWRIGHT_FORCE_ASYNC_LOADER) {
diff --git a/tests/playwright-test/babel.spec.ts b/tests/playwright-test/babel.spec.ts
index ebb480c910..f2098b7f0e 100644
--- a/tests/playwright-test/babel.spec.ts
+++ b/tests/playwright-test/babel.spec.ts
@@ -16,6 +16,8 @@
import { test, expect } from './playwright-test-fixtures';
+test.skip(!!process.env.PW_BUN, 'bun transpiles test files itself');
+
test('should succeed', async ({ runInlineTest }) => {
const result = await runInlineTest({
'one-success.spec.ts': `
diff --git a/tests/playwright-test/cache.spec.ts b/tests/playwright-test/cache.spec.ts
index 132cf8ca6e..7eeb87bc14 100644
--- a/tests/playwright-test/cache.spec.ts
+++ b/tests/playwright-test/cache.spec.ts
@@ -19,6 +19,8 @@ import * as path from 'path';
import { test, expect } from './playwright-test-fixtures';
+test.skip(!!process.env.PW_BUN, 'bun transpiles test files itself, there is no compilation cache');
+
test('should clear cache with type:module', async ({ runCLICommand }) => {
const result = await runCLICommand({
'playwright.config.ts': `
diff --git a/tests/playwright-test/current-test-runner/.gitignore b/tests/playwright-test/current-test-runner/.gitignore
new file mode 100644
index 0000000000..c0bd0b7c80
--- /dev/null
+++ b/tests/playwright-test/current-test-runner/.gitignore
@@ -0,0 +1,2 @@
+/node_modules/
+/.staging/
diff --git a/tests/playwright-test/current-test-runner/README.md b/tests/playwright-test/current-test-runner/README.md
new file mode 100644
index 0000000000..0c7c67c08c
--- /dev/null
+++ b/tests/playwright-test/current-test-runner/README.md
@@ -0,0 +1,3 @@
+This directory holds the current test runner, installed from the local build:
+- `PW_BUN=1 npm run ttest` packs `playwright-core`, `playwright` and `@playwright/test` into `.staging` and installs them here.
+- Inner test projects and their CLI load these copies, not the `packages/` sources.
diff --git a/tests/playwright-test/current-test-runner/globalSetup.ts b/tests/playwright-test/current-test-runner/globalSetup.ts
new file mode 100644
index 0000000000..51bf56cd84
--- /dev/null
+++ b/tests/playwright-test/current-test-runner/globalSetup.ts
@@ -0,0 +1,49 @@
+/**
+ * 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 fs from 'fs';
+import path from 'path';
+import { utils } from '../../../packages/playwright-core/lib/coreBundle';
+
+import type { FullConfig } from '../stable-test-runner';
+
+const { spawnAsync, removeFolders } = utils;
+
+const PACKAGE_BUILDER_SCRIPT = path.join(__dirname, '..', '..', '..', 'utils', 'pack_package.js');
+
+async function globalSetup(config: FullConfig) {
+ const stagingDir = path.join(__dirname, '.staging');
+ const nodeModulesDir = path.join(__dirname, 'node_modules');
+ await removeFolders([stagingDir, nodeModulesDir]);
+ await fs.promises.mkdir(stagingDir, { recursive: true });
+
+ await Promise.all(['playwright-core', 'playwright', 'playwright-test'].map(async packageName => {
+ const { code, stderr, stdout } = await spawnAsync('node', [PACKAGE_BUILDER_SCRIPT, packageName, path.join(stagingDir, `${packageName}.tgz`)]);
+ if (code)
+ throw new Error(`Failed to pack ${packageName}:\n${stderr}\n${stdout}`);
+ }));
+
+ const { code, stderr, stdout } = await spawnAsync('npm', ['install', '--package-lock=false', '--fund=false', '--audit=false'], { cwd: __dirname, shell: process.platform === 'win32' });
+ if (code)
+ throw new Error(`Failed to install current test runner:\n${stderr}\n${stdout}`);
+
+ for (const outputDir of new Set(config.projects.map(p => p.outputDir))) {
+ await fs.promises.mkdir(outputDir, { recursive: true });
+ await fs.promises.symlink(nodeModulesDir, path.join(outputDir, 'node_modules'), 'junction');
+ }
+}
+
+export default globalSetup;
diff --git a/tests/playwright-test/current-test-runner/package.json b/tests/playwright-test/current-test-runner/package.json
new file mode 100644
index 0000000000..15b3ef3682
--- /dev/null
+++ b/tests/playwright-test/current-test-runner/package.json
@@ -0,0 +1,8 @@
+{
+ "private": true,
+ "dependencies": {
+ "@playwright/test": "file:.staging/playwright-test.tgz",
+ "playwright": "file:.staging/playwright.tgz",
+ "playwright-core": "file:.staging/playwright-core.tgz"
+ }
+}
diff --git a/tests/playwright-test/esbuild.spec.ts b/tests/playwright-test/esbuild.spec.ts
index 4e3d2df281..7aea20451e 100644
--- a/tests/playwright-test/esbuild.spec.ts
+++ b/tests/playwright-test/esbuild.spec.ts
@@ -16,6 +16,8 @@
import { test, expect, parseTestRunnerOutput } from './playwright-test-fixtures';
+test.skip(!!process.env.PW_BUN, 'bun transpiles test files itself');
+
const env = { PLAYWRIGHT_EXPERIMENTAL_ESBUILD: '1' };
test('should transpile typescript', async ({ runInlineTest }) => {
diff --git a/tests/playwright-test/esm.spec.ts b/tests/playwright-test/esm.spec.ts
index 5f4022b466..5f1d98434f 100644
--- a/tests/playwright-test/esm.spec.ts
+++ b/tests/playwright-test/esm.spec.ts
@@ -16,6 +16,8 @@
import { test, expect } from './playwright-test-fixtures';
+test.skip(!!process.env.PW_BUN, 'bun loads and resolves modules itself');
+
test('should load nested as esm when package.json has type module', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.js': `
diff --git a/tests/playwright-test/exit-code.spec.ts b/tests/playwright-test/exit-code.spec.ts
index 6fa4e6ab60..92914a81dc 100644
--- a/tests/playwright-test/exit-code.spec.ts
+++ b/tests/playwright-test/exit-code.spec.ts
@@ -27,17 +27,17 @@ test('should collect stdio', async ({ runInlineTest }) => {
import { test, expect } from '@playwright/test';
test('stdio', () => {
process.stdout.write('stdout text');
- process.stdout.write(Buffer.from('stdout buffer'));
+ process.stdout.write(Buffer.from('\\x1b[31mstdout buffer 😀\\x1b[0m'));
process.stderr.write('stderr text');
- process.stderr.write(Buffer.from('stderr buffer'));
+ process.stderr.write(Buffer.from('stderr café', 'latin1'));
});
`
});
expect(exitCode).toBe(0);
const testResult = report.suites[0].specs[0].tests[0].results[0];
const { stdout, stderr } = testResult;
- expect(stdout).toEqual([{ text: 'stdout text' }, { buffer: Buffer.from('stdout buffer').toString('base64') }]);
- expect(stderr).toEqual([{ text: 'stderr text' }, { buffer: Buffer.from('stderr buffer').toString('base64') }]);
+ expect(stdout).toEqual([{ text: 'stdout text' }, { text: '\x1b[31mstdout buffer 😀\x1b[0m' }]);
+ expect(stderr).toEqual([{ text: 'stderr text' }, { buffer: Buffer.from('stderr café', 'latin1').toString('base64') }]);
});
test('should collect stdio from forked process', async ({ runInlineTest }) => {
@@ -60,8 +60,8 @@ test('should collect stdio from forked process', async ({ runInlineTest }) => {
expect(exitCode).toBe(0);
const testResult = report.suites[0].specs[0].tests[0].results[0];
const { stdout, stderr } = testResult;
- expect(stdout.map(e => Buffer.from((e as any).buffer, 'base64').toString()).join('')).toEqual('stdout textstdout buffer');
- expect(stderr.map(e => Buffer.from((e as any).buffer, 'base64').toString()).join('')).toEqual('stderr textstderr buffer');
+ expect(stdout.map(e => (e as any).text).join('')).toEqual('stdout textstdout buffer');
+ expect(stderr.map(e => (e as any).text).join('')).toEqual('stderr textstderr buffer');
});
test('should work with not defined errors', async ({ runInlineTest }) => {
diff --git a/tests/playwright-test/loader.spec.ts b/tests/playwright-test/loader.spec.ts
index 6423c8de00..056f79ddd2 100644
--- a/tests/playwright-test/loader.spec.ts
+++ b/tests/playwright-test/loader.spec.ts
@@ -32,6 +32,7 @@ test('should return the location of a syntax error', async ({ runInlineTest }) =
expect(result.failed).toBe(0);
expect(result.output).toContain('error.spec.js');
expect(result.output).toContain('(3:18)');
+ expect(result.output).toContain(`> 3 | foo: 'bar';\n | ^`);
});
test('should return the location of a syntax error with deep stack', async ({ runInlineTest }) => {
@@ -63,6 +64,7 @@ test('should return the location of a syntax error with deep stack', async ({ ru
`,
});
expect(result.exitCode).toBe(1);
+ expect(result.output).toContain('at error.ts:3');
expect(result.output).toContain('qux.ts:2:');
expect(result.output).toContain('baz.ts:2:');
expect(result.output).toContain('bar.ts:2:');
@@ -82,6 +84,21 @@ test('should print an improper error', async ({ runInlineTest }) => {
expect(result.output).toContain('123');
});
+test('should spread AggregateError sub-errors', async ({ runInlineTest }) => {
+ const result = await runInlineTest({
+ 'error.spec.js': `
+ throw new AggregateError([
+ new AggregateError([new Error('a'), new Error('b')], 'inner'),
+ new Error('c'),
+ ], 'outer');
+ `
+ });
+ expect(result.exitCode).toBe(1);
+ expect(result.output).toContain('Error: a');
+ expect(result.output).toContain('Error: b');
+ expect(result.output).toContain('Error: c');
+});
+
test('should print a null error', async ({ runInlineTest }) => {
const result = await runInlineTest({
'error.spec.js': `
diff --git a/tests/playwright-test/playwright-test-fixtures.ts b/tests/playwright-test/playwright-test-fixtures.ts
index 93ab2ecd79..771fb071c7 100644
--- a/tests/playwright-test/playwright-test-fixtures.ts
+++ b/tests/playwright-test/playwright-test-fixtures.ts
@@ -90,7 +90,9 @@ export async function writeFiles(testInfo: TestInfo, files: Files, initial: bool
return baseDir;
}
-export const cliEntrypoint = path.join(__dirname, '../../packages/playwright-test/cli.js');
+export const cliCommand = process.env.PW_BUN
+ ? ['bun', path.join(__dirname, 'current-test-runner/node_modules/@playwright/test/cli.js')]
+ : ['node', path.join(__dirname, '../../packages/playwright-test/cli.js')];
const configFile = (baseDir: string, files: Files): string | undefined => {
for (const [name, content] of Object.entries(files)) {
@@ -133,7 +135,7 @@ function startPlaywrightTest(childProcess: CommonFixtures['childProcess'], baseD
function startPlaywrightChildProcess(childProcess: CommonFixtures['childProcess'], baseDir: string, args: string[], env: NodeJS.ProcessEnv, options: RunOptions): TestChildProcess {
return childProcess({
- command: ['node', cliEntrypoint, ...args],
+ command: [...cliCommand, ...args],
env: inheritAndCleanEnv(env),
cwd: options.cwd ? path.resolve(baseDir, options.cwd) : baseDir,
});
@@ -208,7 +210,7 @@ async function runPlaywrightTest(childProcess: CommonFixtures['childProcess'], b
async function runPlaywrightCLI(childProcess: CommonFixtures['childProcess'], args: string[], baseDir: string, env: NodeJS.ProcessEnv): Promise<{ output: string, stdout: string, stderr: string, exitCode: number }> {
const testProcess = childProcess({
- command: ['node', cliEntrypoint, ...args],
+ command: [...cliCommand, ...args],
env: inheritAndCleanEnv(env),
cwd: baseDir,
});
@@ -320,7 +322,7 @@ export const test = base
mergeReports: async ({ childProcess }, use) => {
await use(async (reportFolder: string, env: NodeJS.ProcessEnv = {}, options: RunOptions = {}) => {
- const command = ['node', cliEntrypoint, 'merge-reports', reportFolder];
+ const command = [...cliCommand, 'merge-reports', reportFolder];
if (options.additionalArgs)
command.push(...options.additionalArgs);
diff --git a/tests/playwright-test/playwright.config.ts b/tests/playwright-test/playwright.config.ts
index dd2ee01d63..014e890cce 100644
--- a/tests/playwright-test/playwright.config.ts
+++ b/tests/playwright-test/playwright.config.ts
@@ -40,6 +40,7 @@ export default defineConfig({
trace: process.env.PWTEST_COVERAGE ? { mode: 'on', snapshots: false, screenshots: false, _coverage: true } as any : 'off',
},
forbidOnly: !!process.env.CI,
+ globalSetup: process.env.PW_BUN ? './current-test-runner/globalSetup.ts' : undefined,
workers: undefined,
snapshotPathTemplate: '__screenshots__/{testFilePath}/{arg}{ext}',
projects: [
diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts
index 7bb6dbeab9..e7ebd1970e 100644
--- a/tests/playwright-test/reporter-html.spec.ts
+++ b/tests/playwright-test/reporter-html.spec.ts
@@ -18,7 +18,7 @@ import fs from 'fs';
import path from 'path';
import url from 'url';
import * as yazl from 'yazl';
-import { test as baseTest, expect as baseExpect, cliEntrypoint, createImage } from './playwright-test-fixtures';
+import { test as baseTest, expect as baseExpect, cliCommand, createImage } from './playwright-test-fixtures';
import { iso, utils } from '../../packages/playwright-core/lib/coreBundle';
import { mergeServiceWorkerCoverage } from '../config/serviceWorkerCoverage';
@@ -3840,7 +3840,7 @@ test.describe('show-report .zip support', () => {
const port = await findFreePort();
const proc = childProcess({
- command: ['node', cliEntrypoint, 'show-report', zipPath, `--port=${port}`],
+ command: [...cliCommand, 'show-report', zipPath, `--port=${port}`],
cwd: testInfo.outputPath(),
env: { ...process.env, PLAYWRIGHT_HTML_OPEN: 'never' },
});
@@ -3854,7 +3854,7 @@ test.describe('show-report .zip support', () => {
const filePath = testInfo.outputPath('not-a-report.txt');
await fs.promises.writeFile(filePath, 'hello');
const proc = childProcess({
- command: ['node', cliEntrypoint, 'show-report', filePath],
+ command: [...cliCommand, 'show-report', filePath],
cwd: testInfo.outputPath(),
});
const { exitCode } = await proc.exited;
@@ -3871,7 +3871,7 @@ test.describe('show-report .zip support', () => {
await finished;
const proc = childProcess({
- command: ['node', cliEntrypoint, 'show-report', zipPath],
+ command: [...cliCommand, 'show-report', zipPath],
cwd: testInfo.outputPath(),
});
const { exitCode } = await proc.exited;
diff --git a/tests/playwright-test/resolver.spec.ts b/tests/playwright-test/resolver.spec.ts
index 95b9987db7..765718600f 100644
--- a/tests/playwright-test/resolver.spec.ts
+++ b/tests/playwright-test/resolver.spec.ts
@@ -19,6 +19,8 @@ import path from 'path';
import { test, expect } from './playwright-test-fixtures';
+test.skip(!!process.env.PW_BUN, 'bun resolves modules and tsconfig itself');
+
test('should print tsconfig parsing error', async ({ runInlineTest }) => {
const files = {
'a.spec.ts': `
diff --git a/tests/playwright-test/ui-mode-fixtures.ts b/tests/playwright-test/ui-mode-fixtures.ts
index 9b7718625e..19553d6e75 100644
--- a/tests/playwright-test/ui-mode-fixtures.ts
+++ b/tests/playwright-test/ui-mode-fixtures.ts
@@ -18,7 +18,7 @@ import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import type { TestChildProcess } from '../config/commonFixtures';
-import { cliEntrypoint, test as base, writeFiles, removeFolders } from './playwright-test-fixtures';
+import { cliCommand, test as base, writeFiles, removeFolders } from './playwright-test-fixtures';
import type { Files, RunOptions } from './playwright-test-fixtures';
import type { Browser, Page, TestInfo } from './stable-test-runner';
import { chromium, expect as baseExpect } from './stable-test-runner';
@@ -99,7 +99,7 @@ export const test = base
await use(async (files: Files, env: NodeJS.ProcessEnv = {}, options: UIModeOptions = {}) => {
const baseDir = await writeFiles(testInfo, files, true);
testProcess = childProcess({
- command: ['node', cliEntrypoint, 'test', (options.useWeb ? '--ui-host=127.0.0.1' : '--ui'), '--workers=1', ...(options.additionalArgs || [])],
+ command: [...cliCommand, 'test', (options.useWeb ? '--ui-host=127.0.0.1' : '--ui'), '--workers=1', ...(options.additionalArgs || [])],
env: inheritAndCleanEnv({
...env,
PWTEST_CACHE_DIR: cacheDir,
diff --git a/tests/playwright-test/ui-mode-test-run.spec.ts b/tests/playwright-test/ui-mode-test-run.spec.ts
index cfa6ada470..e74f7c7454 100644
--- a/tests/playwright-test/ui-mode-test-run.spec.ts
+++ b/tests/playwright-test/ui-mode-test-run.spec.ts
@@ -582,9 +582,6 @@ test('should ignore repeatEach', async ({ runUITest }) => {
test('should remove output folder before test run', async ({ runUITest }) => {
const { page } = await runUITest({
- 'playwright.config.ts': `
- import { defineConfig } from '@playwright/test';
- `,
'a.test.ts': `
import fs from 'fs';
import { test, expect } from '@playwright/test';
diff --git a/tests/playwright-test/watch.spec.ts b/tests/playwright-test/watch.spec.ts
index d8db08d945..b3e575b802 100644
--- a/tests/playwright-test/watch.spec.ts
+++ b/tests/playwright-test/watch.spec.ts
@@ -17,6 +17,8 @@
import timers from 'timers/promises';
import { test, expect } from './playwright-test-fixtures';
+test.skip(!!process.env.PW_BUN, 'bun does not report module dependencies');
+
test.describe.configure({ mode: 'parallel' });
test('should print dependencies in CJS mode', async ({ runInlineTest }) => {