From 18b008c7209c1cace9c45a5a83a8630156cee3b7 Mon Sep 17 00:00:00 2001 From: "microsoft-playwright-automation[bot]" <203992400+microsoft-playwright-automation[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 21:57:14 +0000 Subject: [PATCH 1/2] fix(test): correct locations on Bun 1.4.4 and later Fixes: https://github.com/microsoft/playwright/issues/43934 --- packages/playwright/src/transform/transform.ts | 9 +++++++-- tests/playwright-test/list-mode.spec.ts | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/playwright/src/transform/transform.ts b/packages/playwright/src/transform/transform.ts index fa6a8dc913563..9082dd093611f 100644 --- a/packages/playwright/src/transform/transform.ts +++ b/packages/playwright/src/transform/transform.ts @@ -412,10 +412,15 @@ function nodeCallerLocation(error: Error, stackFrames: NodeJS.CallSite[]) { }; } +// Bun switched CallSite columns from 0-based to 1-based in 1.4.4. +const bunRuntime = (globalThis as { Bun?: { version: string, semver: { satisfies(version: string, range: string): boolean } } }).Bun; +const bunHasOneBasedColumns = bunRuntime?.semver.satisfies(bunRuntime.version, '>=1.4.4') ?? false; + function bunCallerLocation(error: Error, stackFrames: NodeJS.CallSite[]) { const frame = stackFrames[1]; - // Bun's CallSite.getColumnNumber() is 0-based, and Bun does not apply source maps of .js files. - const position = sourceMapSupport.mapSourcePosition({ source: frame.getFileName()!, line: frame.getLineNumber()!, column: frame.getColumnNumber()! }); + // Bun does not apply source maps of .js files. Source maps take 0-based columns. + const column = frame.getColumnNumber()! - (bunHasOneBasedColumns ? 1 : 0); + const position = sourceMapSupport.mapSourcePosition({ source: frame.getFileName()!, line: frame.getLineNumber()!, column }); return { file: position.source, line: position.line, diff --git a/tests/playwright-test/list-mode.spec.ts b/tests/playwright-test/list-mode.spec.ts index 316ae53cdfcb2..27266546c060f 100644 --- a/tests/playwright-test/list-mode.spec.ts +++ b/tests/playwright-test/list-mode.spec.ts @@ -18,7 +18,9 @@ import { test, expect } from './playwright-test-fixtures'; import path from 'path'; import fs from 'fs'; -test('should list tests', async ({ runInlineTest }) => { +test('should list tests', { + annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43934' }, +}, async ({ runInlineTest }) => { const result = await runInlineTest({ 'playwright.config.ts': ` export default { projects: [{ name: 'foo' }, {}] }; @@ -31,6 +33,7 @@ test('should list tests', async ({ runInlineTest }) => { test('example2', async ({}) => { expect(1 + 1).toBe(2); }); +test('example3', () => {}); ` }, { 'list': true }); expect(result.exitCode).toBe(0); @@ -38,9 +41,11 @@ test('should list tests', async ({ runInlineTest }) => { `Listing tests:`, ` [foo] › a.test.js:3:7 › example1`, ` [foo] › a.test.js:6:7 › example2`, + ` [foo] › a.test.js:9:1 › example3`, ` a.test.js:3:7 › example1`, ` a.test.js:6:7 › example2`, - `Total: 4 tests in 1 file` + ` a.test.js:9:1 › example3`, + `Total: 6 tests in 1 file` ].join('\n')); }); From 84fded5817d6be88da3dc32a5eea72462b311205 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Thu, 5 Nov 2026 14:26:39 -0800 Subject: [PATCH 2/2] fix(test runner): correct test locations on Bun 1.4.4 and later Bun 1.4.4 made CallSite columns 1-based, matching V8, so Bun 1.4.4 and later use the Node location path. The 0-based handling stays for older Bun. The Bun CI job now runs on the latest Bun release. Fixes https://github.com/microsoft/playwright/issues/43934 --- .github/workflows/tests_primary.yml | 2 +- packages/playwright/src/transform/transform.ts | 13 ++++++------- tests/playwright-test/list-mode.spec.ts | 5 +---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests_primary.yml b/.github/workflows/tests_primary.yml index ed7bd75a67455..f5276707f51c2 100644 --- a/.github/workflows/tests_primary.yml +++ b/.github/workflows/tests_primary.yml @@ -82,7 +82,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: - bun-version: 1.4.3 + bun-version: latest - uses: ./.github/actions/run-test with: command: npm run ttest diff --git a/packages/playwright/src/transform/transform.ts b/packages/playwright/src/transform/transform.ts index 9082dd093611f..cd4dc03bff366 100644 --- a/packages/playwright/src/transform/transform.ts +++ b/packages/playwright/src/transform/transform.ts @@ -385,7 +385,7 @@ export function wrapFunctionWithLocation(func: (location: Lo return (...args) => { const oldPrepareStackTrace = Error.prepareStackTrace; const oldStackTraceLimit = Error.stackTraceLimit; - Error.prepareStackTrace = 'Bun' in globalThis ? bunCallerLocation : nodeCallerLocation; + Error.prepareStackTrace = bunHasZeroBasedColumns ? bunCallerLocation : nodeCallerLocation; Error.stackTraceLimit = 2; const obj: { stack: Location } = {} as any; let location: Location; @@ -412,15 +412,14 @@ function nodeCallerLocation(error: Error, stackFrames: NodeJS.CallSite[]) { }; } -// Bun switched CallSite columns from 0-based to 1-based in 1.4.4. -const bunRuntime = (globalThis as { Bun?: { version: string, semver: { satisfies(version: string, range: string): boolean } } }).Bun; -const bunHasOneBasedColumns = bunRuntime?.semver.satisfies(bunRuntime.version, '>=1.4.4') ?? false; +declare const Bun: { version: string, semver: { order(a: string, b: string): number } }; +// Bun's CallSite columns were 0-based before 1.4.4; since then they match V8. +const bunHasZeroBasedColumns = 'Bun' in globalThis && Bun.semver.order(Bun.version, '1.4.4') < 0; function bunCallerLocation(error: Error, stackFrames: NodeJS.CallSite[]) { const frame = stackFrames[1]; - // Bun does not apply source maps of .js files. Source maps take 0-based columns. - const column = frame.getColumnNumber()! - (bunHasOneBasedColumns ? 1 : 0); - const position = sourceMapSupport.mapSourcePosition({ source: frame.getFileName()!, line: frame.getLineNumber()!, column }); + // Bun's CallSite.getColumnNumber() is 0-based, and Bun does not apply source maps of .js files. + const position = sourceMapSupport.mapSourcePosition({ source: frame.getFileName()!, line: frame.getLineNumber()!, column: frame.getColumnNumber()! }); return { file: position.source, line: position.line, diff --git a/tests/playwright-test/list-mode.spec.ts b/tests/playwright-test/list-mode.spec.ts index 27266546c060f..c5e341362add9 100644 --- a/tests/playwright-test/list-mode.spec.ts +++ b/tests/playwright-test/list-mode.spec.ts @@ -33,7 +33,6 @@ test('should list tests', { test('example2', async ({}) => { expect(1 + 1).toBe(2); }); -test('example3', () => {}); ` }, { 'list': true }); expect(result.exitCode).toBe(0); @@ -41,11 +40,9 @@ test('example3', () => {}); `Listing tests:`, ` [foo] › a.test.js:3:7 › example1`, ` [foo] › a.test.js:6:7 › example2`, - ` [foo] › a.test.js:9:1 › example3`, ` a.test.js:3:7 › example1`, ` a.test.js:6:7 › example2`, - ` a.test.js:9:1 › example3`, - `Total: 6 tests in 1 file` + `Total: 4 tests in 1 file` ].join('\n')); });