diff --git a/packages/playwright/src/program.ts b/packages/playwright/src/program.ts index 19eabe6517..883a358a26 100644 --- a/packages/playwright/src/program.ts +++ b/packages/playwright/src/program.ts @@ -337,6 +337,9 @@ function overridesFromOptions(options: { [key: string]: any }): ConfigCLIOverrid overrides.use = overrides.use || {}; overrides.use.trace = options.trace; } + if (overrides.tsconfig && !fs.existsSync(overrides.tsconfig)) + throw new Error(`--tsconfig "${options.tsconfig}" does not exist`); + return overrides; } diff --git a/tests/playwright-test/config.spec.ts b/tests/playwright-test/config.spec.ts index a2c61d62dd..77e5fb23f6 100644 --- a/tests/playwright-test/config.spec.ts +++ b/tests/playwright-test/config.spec.ts @@ -719,14 +719,14 @@ test('should throw on nonexistant config.tsconfig', async ({ runInlineTest }) => tsconfig: './does-not-exist.json', }; `, - 'tests/a.test.ts': ` - import { test, expect } from '@playwright/test'; - test('test', ({}) => { - expect(1).toBe(1); - }); - `, }); expect(result.exitCode).toBe(1); expect(result.output).toContain(`config.tsconfig does not exist`); }); + +test('should throw on invalid --tsconfig', async ({ runInlineTest }) => { + const result = await runInlineTest({}, { 'tsconfig': 'does-not-exist.json' }); + expect(result.exitCode).toBe(1); + expect(result.output).toContain(`--tsconfig "does-not-exist.json" does not exist`); +});