fix(test runner): improve error message when not able to parse tsconfig (#32526)
This commit is contained in:
parent
e6c5b6054d
commit
6bb005db85
|
|
@ -53,9 +53,13 @@ export interface LoadedTsConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadTsConfig(configPath: string): LoadedTsConfig[] {
|
export function loadTsConfig(configPath: string): LoadedTsConfig[] {
|
||||||
const references: LoadedTsConfig[] = [];
|
try {
|
||||||
const config = innerLoadTsConfig(configPath, references);
|
const references: LoadedTsConfig[] = [];
|
||||||
return [config, ...references];
|
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) {
|
function resolveConfigFile(baseConfigFile: string, referencedConfigFile: string) {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,24 @@
|
||||||
|
|
||||||
import { test, expect } from './playwright-test-fixtures';
|
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('should respect path resolver', async ({ runInlineTest }) => {
|
||||||
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/11656' });
|
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/11656' });
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue