Skip to content

Commit 01b9c15

Browse files
fix(test runner): correct test locations on Bun 1.4.4 and later (#43942)
Co-authored-by: microsoft-playwright-automation[bot] <203992400+microsoft-playwright-automation[bot]@users.noreply.github.com> Co-authored-by: Pavel Feldman <pavel.feldman@gmail.com>
1 parent 89c9341 commit 01b9c15

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎.github/workflows/tests_primary.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
8383
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
8484
with:
85-
bun-version: 1.4.3
85+
bun-version: latest
8686
- uses: ./.github/actions/run-test
8787
with:
8888
command: npm run ttest

‎packages/playwright/src/transform/transform.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ export function wrapFunctionWithLocation<A extends any[], R>(func: (location: Lo
385385
return (...args) => {
386386
const oldPrepareStackTrace = Error.prepareStackTrace;
387387
const oldStackTraceLimit = Error.stackTraceLimit;
388-
Error.prepareStackTrace = 'Bun' in globalThis ? bunCallerLocation : nodeCallerLocation;
388+
Error.prepareStackTrace = bunHasZeroBasedColumns ? bunCallerLocation : nodeCallerLocation;
389389
Error.stackTraceLimit = 2;
390390
const obj: { stack: Location } = {} as any;
391391
let location: Location;
@@ -412,6 +412,10 @@ function nodeCallerLocation(error: Error, stackFrames: NodeJS.CallSite[]) {
412412
};
413413
}
414414

415+
declare const Bun: { version: string, semver: { order(a: string, b: string): number } };
416+
// Bun's CallSite columns were 0-based before 1.4.4; since then they match V8.
417+
const bunHasZeroBasedColumns = 'Bun' in globalThis && Bun.semver.order(Bun.version, '1.4.4') < 0;
418+
415419
function bunCallerLocation(error: Error, stackFrames: NodeJS.CallSite[]) {
416420
const frame = stackFrames[1];
417421
// Bun's CallSite.getColumnNumber() is 0-based, and Bun does not apply source maps of .js files.

‎tests/playwright-test/list-mode.spec.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import { test, expect } from './playwright-test-fixtures';
1818
import path from 'path';
1919
import fs from 'fs';
2020

21-
test('should list tests', async ({ runInlineTest }) => {
21+
test('should list tests', {
22+
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43934' },
23+
}, async ({ runInlineTest }) => {
2224
const result = await runInlineTest({
2325
'playwright.config.ts': `
2426
export default { projects: [{ name: 'foo' }, {}] };

0 commit comments

Comments
 (0)