From a6a2ba7d3d216471523707d3c5ba2fa3c74b7a1d Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Sun, 15 Mar 2026 11:09:50 -0700 Subject: [PATCH 1/2] fix(test): use relative path in error-context location (#39676) --- packages/playwright/src/errorContext.ts | 4 +++- .../playwright.artifacts.spec.ts | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/playwright/src/errorContext.ts b/packages/playwright/src/errorContext.ts index a7655f4ce0cb7..a5ab393a82e96 100644 --- a/packages/playwright/src/errorContext.ts +++ b/packages/playwright/src/errorContext.ts @@ -19,6 +19,8 @@ import path from 'path'; import { parseErrorStack, stripAnsiEscapes } from 'playwright-core/lib/utils'; +import { relativeFilePath } from './util'; + import type { TestInfoError } from '../types/test'; const fixTestInstructions = `# Instructions @@ -46,7 +48,7 @@ export function buildErrorContext(options: { '# Test info', '', `- Name: ${titlePath.join(' >> ')}`, - `- Location: ${location.file}:${location.line}:${location.column}`, + `- Location: ${relativeFilePath(location.file)}:${location.line}:${location.column}`, ]; if (meaningfulErrors.length) { diff --git a/tests/playwright-test/playwright.artifacts.spec.ts b/tests/playwright-test/playwright.artifacts.spec.ts index c9dbecf180d44..1ea81bdca904a 100644 --- a/tests/playwright-test/playwright.artifacts.spec.ts +++ b/tests/playwright-test/playwright.artifacts.spec.ts @@ -572,6 +572,27 @@ test('should work with trace: retain-on-failure-and-retries', async ({ runInline ]); }); +test('error-context should use relative path in location', async ({ runInlineTest }, testInfo) => { + const result = await runInlineTest({ + 'a.spec.ts': ` + import { test, expect } from '@playwright/test'; + test('fail', async ({ page }) => { + expect(1).toBe(2); + }); + `, + }, { workers: 1 }); + + expect(result.exitCode).toBe(1); + expect(result.failed).toBe(1); + + const errorContextPath = testInfo.outputPath('test-results', 'a-fail', 'error-context.md'); + const content = fs.readFileSync(errorContextPath, 'utf8'); + const locationLine = content.split('\n').find(line => line.startsWith('- Location:'))!; + expect(locationLine).toBeTruthy(); + // Location should be a relative path, not absolute. + expect(locationLine).toContain('- Location: a.spec.ts:'); +}); + test('should take screenshot when page is closed in afterEach', async ({ runInlineTest }, testInfo) => { const result = await runInlineTest({ 'playwright.config.ts': ` From ef45dd4be704a2f161c63fcf0dedbf2b6913d823 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Sun, 15 Mar 2026 14:09:41 -0700 Subject: [PATCH 2/2] fix(npm): include JSON and skill markdown files in bundle (#39689) --- packages/playwright-core/.npmignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/playwright-core/.npmignore b/packages/playwright-core/.npmignore index 6c22b80f90d2a..119bbff9eb57c 100644 --- a/packages/playwright-core/.npmignore +++ b/packages/playwright-core/.npmignore @@ -10,6 +10,8 @@ !lib/**/*.png !lib/**/*.svg !lib/**/*.ttf +!lib/**/*.json +!lib/skill/**/*.md !lib/utilsBundleImpl/xdg-open !lib/**/manifest.webmanifest # Exclude injected files. A preprocessed version of these is included via lib/generated. @@ -37,6 +39,4 @@ lib/**/injected/ !NOTICE # Include browser descriptors. !browsers.json -# Include generated devices descriptors -!deviceDescriptorsSource.json !ThirdPartyNotices.txt