Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(test runner): improve error message when not able to parse tsconfig (#32526)
Dmitry Gozman6bb005db85c0
diff --git a/packages/playwright/src/third_party/tsconfig-loader.ts b/packages/playwright/src/third_party/tsconfig-loader.tsindex 61ad11a3bd..b654a3b963 100644--- a/packages/playwright/src/third_party/tsconfig-loader.ts+++ b/packages/playwright/src/third_party/tsconfig-loader.ts@@ -53,9 +53,13 @@ export interface LoadedTsConfig {}export function loadTsConfig(configPath: string): LoadedTsConfig[] {- const references: LoadedTsConfig[] = [];- const config = innerLoadTsConfig(configPath, references);- return [config, ...references];+ try {+ const references: LoadedTsConfig[] = [];+ const config = innerLoadTsConfig(configPath, references);+ return [config, ...references];+ } catch (e) {+ throw new Error(`Failed to load tsconfig file at ${configPath}:\n${e.message}`);+ }}function resolveConfigFile(baseConfigFile: string, referencedConfigFile: string) {diff --git a/tests/playwright-test/resolver.spec.ts b/tests/playwright-test/resolver.spec.tsindex 5a0e91b099..e06959558c 100644--- a/tests/playwright-test/resolver.spec.ts+++ b/tests/playwright-test/resolver.spec.ts@@ -16,6 +16,24 @@import { test, expect } from './playwright-test-fixtures';+test('should print tsconfig parsing error', async ({ runInlineTest }) => {+ const files = {+ 'a.spec.ts': `+ import { test } from '@playwright/test';+ test('pass', async () => {});+ `,+ 'tsconfig.json': `+ "foo": "bar"+ `,+ };++ const result = await runInlineTest(files);+ expect(result.exitCode).toBe(1);+ expect(result.output).toContain(`Failed to load tsconfig file at`);+ expect(result.output).toContain(`tsconfig.json`);+ expect(result.output).toContain(`JSON5: invalid character ':' at 2:12`);+});+test('should respect path resolver', async ({ runInlineTest }) => {test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/11656' });