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): remove experimental esbuild transpilation (#43411)

Pavel Feldman343d8e7d0f59
diff --git a/package-lock.json b/package-lock.json
index 9f0f82d48d..754e76686a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1226,6 +1226,7 @@
"cpu": [
"ppc64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1242,6 +1243,7 @@
"cpu": [
"arm"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1258,6 +1260,7 @@
"cpu": [
"arm64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1274,6 +1277,7 @@
"cpu": [
"x64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1290,6 +1294,7 @@
"cpu": [
"arm64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1306,6 +1311,7 @@
"cpu": [
"x64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1322,6 +1328,7 @@
"cpu": [
"arm64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1338,6 +1345,7 @@
"cpu": [
"x64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1354,6 +1362,7 @@
"cpu": [
"arm"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1370,6 +1379,7 @@
"cpu": [
"arm64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1386,6 +1396,7 @@
"cpu": [
"ia32"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1402,6 +1413,7 @@
"cpu": [
"loong64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1418,6 +1430,7 @@
"cpu": [
"mips64el"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1434,6 +1447,7 @@
"cpu": [
"ppc64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1450,6 +1464,7 @@
"cpu": [
"riscv64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1466,6 +1481,7 @@
"cpu": [
"s390x"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1482,6 +1498,7 @@
"cpu": [
"x64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1498,6 +1515,7 @@
"cpu": [
"arm64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1514,6 +1532,7 @@
"cpu": [
"x64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1530,6 +1549,7 @@
"cpu": [
"arm64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1546,6 +1566,7 @@
"cpu": [
"x64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1562,6 +1583,7 @@
"cpu": [
"arm64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1578,6 +1600,7 @@
"cpu": [
"x64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1594,6 +1617,7 @@
"cpu": [
"arm64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1610,6 +1634,7 @@
"cpu": [
"ia32"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1626,6 +1651,7 @@
"cpu": [
"x64"
],
+ "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -4904,7 +4930,7 @@
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.1.tgz",
"integrity": "sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==",
- "devOptional": true,
+ "dev": true,
"hasInstallScript": true,
"license": "MIT",
"bin": {
@@ -9727,14 +9753,6 @@
},
"engines": {
"node": ">=20"
- },
- "peerDependencies": {
- "esbuild": ">=0.21.5"
- },
- "peerDependenciesMeta": {
- "esbuild": {
- "optional": true
- }
}
},
"packages/playwright-browser-chromium": {
diff --git a/packages/playwright/package.json b/packages/playwright/package.json
index 7779613bcb..e2ae11459f 100644
--- a/packages/playwright/package.json
+++ b/packages/playwright/package.json
@@ -46,13 +46,5 @@
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "1.65.0-next"
- },
- "peerDependencies": {
- "esbuild": ">=0.21.5"
- },
- "peerDependenciesMeta": {
- "esbuild": {
- "optional": true
- }
}
}
diff --git a/packages/playwright/src/transform/esbuildTransform.ts b/packages/playwright/src/transform/esbuildTransform.ts
deleted file mode 100644
index d116d111e3..0000000000
--- a/packages/playwright/src/transform/esbuildTransform.ts
+++ /dev/null
@@ -1,88 +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 path from 'path';
-
-import type * as esbuild from 'esbuild';
-import type { JsxOptions } from './babelBundle';
-
-export type Esbuild = typeof esbuild;
-
-export function loadEsbuild(): Esbuild {
- try {
- return require('esbuild');
- } catch (error) {
- throw new Error(`PLAYWRIGHT_EXPERIMENTAL_ESBUILD requires the "esbuild" package, install it with "npm install --save-dev esbuild"`, { cause: error });
- }
-}
-
-export function esbuildTransform(esbuild: Esbuild, code: string, filename: string, isModule: boolean, useDefineForClassFields: boolean, jsx: JsxOptions | undefined): { code: string, map: any } {
- const options = transformOptions(filename, isModule, useDefineForClassFields, jsx);
- let result: esbuild.TransformResult;
- try {
- result = transformSync(esbuild, code, options);
- } catch (error) {
- throw toSyntaxError(error, filename);
- }
- return { code: result.code, map: JSON.parse(result.map) };
-}
-
-function transformOptions(filename: string, isModule: boolean, useDefineForClassFields: boolean, jsx: JsxOptions | undefined): esbuild.TransformOptions {
- const ext = path.extname(filename);
- const jsxMode = jsx?.jsx ?? 'react-jsx';
- return {
- sourcefile: filename,
- loader: ext === '.tsx' ? 'tsx' : ['.ts', '.mts', '.cts'].includes(ext) ? 'ts' : 'jsx',
- format: isModule ? 'esm' : 'cjs',
- platform: 'node',
- target: 'node' + process.versions.node.split('-')[0],
- sourcemap: 'both',
- jsx: jsxMode === 'react' ? 'transform' : 'automatic',
- jsxDev: jsxMode === 'react-jsxdev',
- jsxFactory: jsx?.jsxFactory,
- jsxFragment: jsx?.jsxFragmentFactory,
- jsxImportSource: jsx?.jsxImportSource,
- tsconfigRaw: {
- compilerOptions: {
- useDefineForClassFields,
- alwaysStrict: true,
- },
- },
- logLevel: 'silent',
- };
-}
-
-function transformSync(esbuild: Esbuild, code: string, options: esbuild.TransformOptions): esbuild.TransformResult {
- try {
- return esbuild.transformSync(code, options);
- } catch (error) {
- // Ctrl+C terminates esbuild's service process along with the whole process group.
- if (!(error instanceof Error) || !/^The service (is no longer running|was stopped)/.test(error.message))
- throw error;
- void esbuild.stop();
- return esbuild.transformSync(code, options);
- }
-}
-
-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 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 e3f6ef9144..fa04811e3e 100644
--- a/packages/playwright/src/transform/transform.ts
+++ b/packages/playwright/src/transform/transform.ts
@@ -24,7 +24,6 @@ import { loadTsConfig } from './tsconfig-loader';
import { libPath, packageJSON } from '../package';
import { createFileMatcher, debugTest, fileIsModule, resolveImportSpecifierAfterMapping } from '../util';
import * as cc from './compilationCache';
-import { esbuildTransform, loadEsbuild } from './esbuildTransform';
import * as esmLoaderSync from './esmLoaderSync';
import { addHook } from './pirates';
import { PortTransport } from './portTransport';
@@ -239,9 +238,7 @@ export function hasTransformedExtension(filename: string): boolean {
}
export function transformHook(originalCode: string, filename: string, moduleUrl?: string): { code: string, serializedCache?: any } {
- const esbuild = process.env.PLAYWRIGHT_EXPERIMENTAL_ESBUILD ? loadEsbuild() : undefined;
const hasPreprocessor =
- !esbuild &&
process.env.PW_TEST_SOURCE_TRANSFORM &&
process.env.PW_TEST_SOURCE_TRANSFORM_SCOPE &&
process.env.PW_TEST_SOURCE_TRANSFORM_SCOPE.split(pathSeparator).some(f => filename.startsWith(f));
@@ -250,17 +247,11 @@ export function transformHook(originalCode: string, filename: string, moduleUrl?
const jsx = tsconfigs.find(tsconfig => tsconfig.jsx)?.jsx;
// Without "target", tsc defaults to the latest one, which defines class fields.
const useDefineForClassFields = tsconfigs.find(tsconfig => tsconfig.useDefineForClassFields !== undefined)?.useDefineForClassFields ?? true;
- const hash = calculateHash(originalCode, filename, !!moduleUrl, pluginsEpilogue, useDefineForClassFields, jsx, esbuild?.version);
+ const hash = calculateHash(originalCode, filename, !!moduleUrl, pluginsEpilogue, useDefineForClassFields, jsx);
const { cachedCode, addToCache, serializedCache } = cc.getFromCompilationCache(filename, hash, moduleUrl);
if (cachedCode !== undefined)
return { code: cachedCode, serializedCache };
- if (esbuild) {
- const { code, map } = esbuildTransform(esbuild, originalCode, filename, !!moduleUrl, useDefineForClassFields, jsx);
- const added = addToCache!(code, map);
- return { code, serializedCache: added.serializedCache };
- }
-
// We don't use any browserslist data, but babel checks it anyway.
// Silence the annoying warning.
process.env.BROWSERSLIST_IGNORE_OLD_DATA = 'true';
@@ -274,7 +265,7 @@ export function transformHook(originalCode: string, filename: string, moduleUrl?
return { code, serializedCache: added.serializedCache };
}
-function calculateHash(content: string, filePath: string, isModule: boolean, pluginsEpilogue: BabelPlugin[], useDefineForClassFields: boolean, jsx: JsxOptions | undefined, esbuildVersion: string | undefined): string {
+function calculateHash(content: string, filePath: string, isModule: boolean, pluginsEpilogue: BabelPlugin[], useDefineForClassFields: boolean, jsx: JsxOptions | undefined): string {
const hash = crypto.createHash('sha1')
.update(isModule ? 'esm' : 'no_esm')
.update(content)
@@ -283,7 +274,6 @@ function calculateHash(content: string, filePath: string, isModule: boolean, plu
.update(pluginsEpilogue.map(p => p[0]).join(','))
.update(useDefineForClassFields ? 'define' : 'assign')
.update(jsx ? JSON.stringify(jsx) : '')
- .update(esbuildVersion ? 'esbuild@' + esbuildVersion : '')
.digest('hex');
return hash;
}
diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.ts
index e031dc3f48..adc0f07e99 100644
--- a/tests/library/trace-viewer.spec.ts
+++ b/tests/library/trace-viewer.spec.ts
@@ -432,7 +432,7 @@ test('should show params and return value', async ({ showTraceViewer }) => {
/Evaluate/,
/start:[\d\.]+m?s/,
/duration:[\d]+ms/,
- /expression:"\({[↵\s]*a[↵\s]*}\) => {↵\s*console\.log\(['"]Info['"]\);↵\s*console\.warn\(['"]Warning['"]\);↵\s*console/,
+ /expression:"\({↵ a↵ }\) => {↵ console\.log\(\'Info\'\);↵ console\.warn\(\'Warning\'\);↵ console/,
'isFunction:true',
'arg:{"a":"paramA","b":4}',
'value:"return paramA"'
diff --git a/tests/page/page-evaluate-callback.spec.ts b/tests/page/page-evaluate-callback.spec.ts
index 9862dbe69d..1c4edf7100 100644
--- a/tests/page/page-evaluate-callback.spec.ts
+++ b/tests/page/page-evaluate-callback.spec.ts
@@ -19,7 +19,7 @@ import { test as it, expect } from './pageTest';
it('should throw without the exposeFunctions option', async ({ page }) => {
await expect(page.evaluate(({ cb }) => cb(), { cb: () => {} }))
- .rejects.toThrow(/Attempting to serialize unexpected value at position "cb": \(\) => {\s*}/);
+ .rejects.toThrow(/Attempting to serialize unexpected value at position "cb": \(\) => {}/);
});
it('should call a function passed as an argument', async ({ page }) => {
diff --git a/tests/page/page-evaluate.spec.ts b/tests/page/page-evaluate.spec.ts
index 3744ac57ea..30cd7a3462 100644
--- a/tests/page/page-evaluate.spec.ts
+++ b/tests/page/page-evaluate.spec.ts
@@ -482,22 +482,22 @@ it('should throw for too deep reference chain 2', {
it('should throw usable message for unserializable shallow function', async ({ page }) => {
await expect(() => page.evaluate(arg => arg, () => { }))
- .rejects.toThrow(/Attempting to serialize unexpected value: \(\) => {\s*}/);
+ .rejects.toThrow(/Attempting to serialize unexpected value: \(\) => {}/);
});
it('should throw usable message for unserializable object one deep function', async ({ page }) => {
await expect(() => page.evaluate(arg => arg, { aProperty: () => { } }))
- .rejects.toThrow(/Attempting to serialize unexpected value at position "aProperty": \(\) => {\s*}/);
+ .rejects.toThrow(/Attempting to serialize unexpected value at position "aProperty": \(\) => {}/);
});
it('should throw usable message for unserializable object nested function', async ({ page }) => {
await expect(() => page.evaluate(arg => arg, { a: { inner: { property: () => { } } } }))
- .rejects.toThrow(/Attempting to serialize unexpected value at position "a\.inner\.property": \(\) => {\s*}/);
+ .rejects.toThrow(/Attempting to serialize unexpected value at position "a\.inner\.property": \(\) => {}/);
});
it('should throw usable message for unserializable array nested function', async ({ page }) => {
await expect(() => page.evaluate(arg => arg, { a: { inner: ['firstValue', { property: () => { } }] } }))
- .rejects.toThrow(/Attempting to serialize unexpected value at position "a\.inner\[1\]\.property": \(\) => {\s*}/);
+ .rejects.toThrow(/Attempting to serialize unexpected value at position "a\.inner\[1\]\.property": \(\) => {}/);
});
it('should alias Window, Document and Node', async ({ page }) => {
diff --git a/tests/playwright-test/babel.spec.ts b/tests/playwright-test/babel.spec.ts
index f2098b7f0e..a98810876f 100644
--- a/tests/playwright-test/babel.spec.ts
+++ b/tests/playwright-test/babel.spec.ts
@@ -236,7 +236,6 @@ for (const type of ['module', undefined]) {
description: 'https://github.com/microsoft/playwright/issues/32659'
}
}, async ({ runInlineTest }) => {
- test.skip(type === 'module' && !!process.env.PLAYWRIGHT_EXPERIMENTAL_ESBUILD, 'esbuild drops "assert" import attributes');
const result = await runInlineTest({
'playwright.config.ts': `
import packageJSON from './package.json' assert { type: 'json' };
@@ -260,7 +259,6 @@ for (const type of ['module', undefined]) {
}
test('should allow overwriting exports of a transpiled module', async ({ runInlineTest }) => {
- test.skip(!!process.env.PLAYWRIGHT_EXPERIMENTAL_ESBUILD, 'esbuild exports are getters');
const result = await runInlineTest({
'util.ts': `
export function greet() { return 'real'; }
@@ -285,7 +283,6 @@ test('should allow overwriting exports of a transpiled module', async ({ runInli
});
test('should read undefined from an uninitialized import in a cycle', async ({ runInlineTest }) => {
- test.skip(!!process.env.PLAYWRIGHT_EXPERIMENTAL_ESBUILD, 'esbuild throws on uninitialized imports');
const result = await runInlineTest({
'a.ts': `
import './b';
@@ -311,7 +308,6 @@ test('should read undefined from an uninitialized import in a cycle', async ({ r
});
test('should parse generic arrow functions in tsx', async ({ runInlineTest }) => {
- test.skip(!!process.env.PLAYWRIGHT_EXPERIMENTAL_ESBUILD, 'esbuild does not parse generic arrow functions in tsx');
const result = await runInlineTest({
'example.spec.tsx': `
import { test, expect } from '@playwright/test';
@@ -328,7 +324,6 @@ test('should parse generic arrow functions in tsx', async ({ runInlineTest }) =>
});
test('should reject import.meta in commonjs', async ({ runInlineTest }) => {
- test.skip(!!process.env.PLAYWRIGHT_EXPERIMENTAL_ESBUILD, 'esbuild replaces import.meta with {}');
const result = await runInlineTest({
'example.spec.ts': `
import { test, expect } from '@playwright/test';
diff --git a/tests/playwright-test/esbuild.spec.ts b/tests/playwright-test/esbuild.spec.ts
deleted file mode 100644
index 7aea20451e..0000000000
--- a/tests/playwright-test/esbuild.spec.ts
+++ /dev/null
@@ -1,177 +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 { 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 }) => {
- const result = await runInlineTest({
- 'tsconfig.json': `{
- "compilerOptions": { "jsx": "react", "jsxFactory": "h" },
- }`,
- 'a.spec.ts': `
- import { test, expect } from '@playwright/test';
-
- enum Direction { Up = 1, Down }
- namespace Shapes { export const sides = 4; }
- namespace Shapes { export const corners = sides; }
-
- function tagged(value: any, context: ClassMethodDecoratorContext) {
- return function (this: any) { return 'tagged:' + value.call(this); };
- }
-
- class Base {
- page: string;
- constructor(page: string) { this.page = page; }
- }
-
- class LoginPage extends Base {
- declare page: string;
- readonly title = this.page + '-title';
- constructor(page: string, private readonly user = 'admin') { super(page); }
- @tagged name() { return this.user; }
- }
-
- test('works', () => {
- expect(Direction.Down).toBe(2);
- expect(Shapes.corners).toBe(4);
- const loginPage = new LoginPage('login');
- expect(loginPage.page).toBe('login');
- expect(loginPage.title).toBe('login-title');
- expect(loginPage.name()).toBe('tagged:admin');
- });
- `,
- 'b.spec.tsx': `
- import { test, expect } from '@playwright/test';
- const h = (tag: string, props: any, ...children: any[]) => ({ tag, props, children });
- test('jsx', () => {
- expect(<div id="x">text</div>).toEqual({ tag: 'div', props: { id: 'x' }, children: ['text'] });
- });
- `,
- }, {}, env);
- expect(result.exitCode).toBe(0);
- expect(result.passed).toBe(2);
-});
-
-test('should assign class fields for older targets', async ({ runInlineTest }) => {
- const result = await runInlineTest({
- 'tsconfig.json': JSON.stringify({ compilerOptions: { target: 'ES2021' } }),
- 'a.spec.ts': `
- import { test, expect } from '@playwright/test';
-
- class Base {
- redeclared = 'base';
- setterCalls: string[] = [];
- set overridden(value: string) { this.setterCalls.push(value); }
- }
-
- class Derived extends Base {
- redeclared: string;
- overridden = 'derived';
- fromParameter = this.parameter + '-field';
- constructor(private parameter: string) { super(); }
- }
-
- test('works', () => {
- const derived = new Derived('parameter');
- expect(derived.redeclared).toBe('base');
- expect(derived.setterCalls).toEqual(['derived']);
- expect(derived.fromParameter).toBe('parameter-field');
- });
- `,
- }, {}, env);
- expect(result.exitCode).toBe(0);
- expect(result.passed).toBe(1);
-});
-
-test('should map locations to sources', async ({ runInlineTest }) => {
- const result = await runInlineTest({
- 'a.spec.ts': `
- import { test, expect } from '@playwright/test';
- enum Answer { Yes = 'yes' }
- test('fails', () => {
- expect(Answer.Yes as string).toBe('no');
- });
- `,
- }, { reporter: 'list' }, env);
- expect(result.exitCode).toBe(1);
- expect(result.output).toContain('a.spec.ts:4:7 › fails');
- expect(result.output).toContain(`> 5 | expect(Answer.Yes as string).toBe('no');`);
- expect(result.output).toContain('a.spec.ts:5:38');
-});
-
-test('should support ESM packages', async ({ runInlineTest }) => {
- const result = await runInlineTest({
- 'package.json': `{ "type": "module" }`,
- 'playwright.config.ts': `
- import type { PlaywrightTestConfig } from '@playwright/test';
- const config: PlaywrightTestConfig = { projects: [{ name: 'esm' }] };
- export default config;
- `,
- 'helper.ts': `
- export enum Color { Red = 'red' }
- export class Box { constructor(readonly color: Color) {} }
- `,
- 'a.spec.ts': `
- import { test, expect } from '@playwright/test';
- import { Box, Color } from './helper';
- test('works', () => {
- expect(new Box(Color.Red).color).toBe('red');
- });
- `,
- }, {}, env);
- expect(result.exitCode).toBe(0);
- expect(result.passed).toBe(1);
-});
-
-test('should transpile global teardown after sigint', async ({ interactWithTestRunner }) => {
- test.skip(process.platform === 'win32', 'No sending SIGINT on Windows');
-
- const testProcess = await interactWithTestRunner({
- 'playwright.config.ts': `
- export default {
- globalSetup: './globalSetup.ts',
- globalTeardown: './globalTeardown.ts',
- };
- `,
- 'globalSetup.ts': `
- export default () => {
- console.log('Global setup');
- console.log('%%SEND-SIGINT%%');
- return new Promise(f => setTimeout(f, 30000));
- };
- `,
- 'globalTeardown.ts': `
- export default (): void => {
- console.log('Global teardown');
- };
- `,
- 'a.spec.ts': `
- import { test } from '@playwright/test';
- test('test', async () => {});
- `,
- }, { workers: 1 }, env);
- await testProcess.waitForOutput('%%SEND-SIGINT%%');
- process.kill(-testProcess.process.pid!, 'SIGINT');
- const { exitCode } = await testProcess.exited;
- expect(exitCode).toBe(130);
-
- const result = parseTestRunnerOutput(testProcess.output);
- expect(result.output).toContain('Global teardown');
-});
diff --git a/tests/playwright-test/list-mode.spec.ts b/tests/playwright-test/list-mode.spec.ts
index 0679932499..316ae53cdf 100644
--- a/tests/playwright-test/list-mode.spec.ts
+++ b/tests/playwright-test/list-mode.spec.ts
@@ -193,7 +193,7 @@ test('should report errors with location', async ({ runInlineTest }) => {
expect(JSON.parse(result.outputLines[0])).toEqual({
file: expect.stringContaining('a.test.js'),
line: 3,
- column: expect.any(Number),
+ column: 9,
});
});
diff --git a/tests/playwright-test/loader.spec.ts b/tests/playwright-test/loader.spec.ts
index 056f79ddd2..2593737b3e 100644
--- a/tests/playwright-test/loader.spec.ts
+++ b/tests/playwright-test/loader.spec.ts
@@ -65,11 +65,11 @@ 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:');
- expect(result.output).toContain('foo.ts:2:');
- expect(result.output).toContain('test.spec.ts:2:');
+ expect(result.output).toContain('qux.ts:2:7');
+ expect(result.output).toContain('baz.ts:2:7');
+ expect(result.output).toContain('bar.ts:2:7');
+ expect(result.output).toContain('foo.ts:2:7');
+ expect(result.output).toContain('test.spec.ts:2:7');
});
test('should print an improper error', async ({ runInlineTest }) => {
diff --git a/tests/playwright-test/test-server.spec.ts b/tests/playwright-test/test-server.spec.ts
index 760da65287..931c0f48c0 100644
--- a/tests/playwright-test/test-server.spec.ts
+++ b/tests/playwright-test/test-server.spec.ts
@@ -208,7 +208,7 @@ test('find related test files errors', async ({ startTestServer, writeFiles }) =
const aSpecTs = test.info().outputPath('a.spec.ts');
const result = await testServerConnection.findRelatedTestFiles({ files: [aSpecTs] });
expect(result).toEqual({ testFiles: [], errors: [
- expect.objectContaining({ message: expect.stringContaining(process.env.PLAYWRIGHT_EXPERIMENTAL_ESBUILD ? `The symbol "a" has already been declared` : `Identifier 'a' has already been declared`) }),
+ expect.objectContaining({ message: expect.stringContaining(`Identifier 'a' has already been declared`) }),
expect.objectContaining({ message: expect.stringContaining(`No tests found`) }),
] });
diff --git a/tests/playwright-test/ui-mode-test-output.spec.ts b/tests/playwright-test/ui-mode-test-output.spec.ts
index 42e8ae7acb..b6230b5bfa 100644
--- a/tests/playwright-test/ui-mode-test-output.spec.ts
+++ b/tests/playwright-test/ui-mode-test-output.spec.ts
@@ -29,7 +29,7 @@ test('should print load errors', async ({ runUITest }) => {
`,
});
await page.getByTitle('Toggle output').click();
- await expect(page.getByTestId('output')).toContainText(process.env.PLAYWRIGHT_EXPERIMENTAL_ESBUILD ? `"await" can only be used inside an "async" function` : `Unexpected reserved word 'await'`);
+ await expect(page.getByTestId('output')).toContainText(`Unexpected reserved word 'await'`);
});
test('should work after theme switch', async ({ runUITest, writeFiles }) => {
@@ -190,12 +190,12 @@ test('should format console messages in page', async ({ runUITest }, testInfo) =
await expect(page.locator('.console-tab')).toMatchAriaSnapshot(`
- listbox:
- - option /<anonymous>:\\d+ Object/
- - option /<anonymous>:\\d+ Date/
- - option /<anonymous>:\\d+ Regex/
- - option /<anonymous>:\\d+ Number 0 one 2/
- - option /<anonymous>:\\d+ Download the React DevTools/
- - option /<anonymous>:\\d+ Array of values/
+ - option /<anonymous>:1 Object/
+ - option /<anonymous>:4 Date/
+ - option /<anonymous>:5 Regex/
+ - option /<anonymous>:6 Number 0 one 2/
+ - option /<anonymous>:7 Download the React DevTools/
+ - option /<anonymous>:8 Array of values/
- option /Failed to load resource/
`);
diff --git a/tests/playwright-test/ui-mode-test-source.spec.ts b/tests/playwright-test/ui-mode-test-source.spec.ts
index 21c49984c3..a22a142587 100644
--- a/tests/playwright-test/ui-mode-test-source.spec.ts
+++ b/tests/playwright-test/ui-mode-test-source.spec.ts
@@ -154,7 +154,7 @@ test('should show syntax errors in file', async ({ runUITest }) => {
await expect(
page.locator('.CodeMirror-linewidget')
).toHaveText([
- process.env.PLAYWRIGHT_EXPERIMENTAL_ESBUILD ? /Expected ";" but found "&"/ : /Missing semicolon./
+ /Missing semicolon./
]);
});
diff --git a/utils/build/build.js b/utils/build/build.js
index bd57605768..2a8d24c64f 100644
--- a/utils/build/build.js
+++ b/utils/build/build.js
@@ -755,7 +755,6 @@ steps.push(new CustomCallbackStep(assertCoreBundleHasNoNodeModules));
external: [
'playwright-core',
'playwright-core/*',
- 'esbuild',
'../package',
'../globals',
'../transform/esmLoader.js',
@@ -814,7 +813,6 @@ steps.push(new EsbuildStep({
'playwright-core',
'playwright-core/*',
'playwright',
- 'esbuild',
'../globals',
'../package',
'../utils',