add cli check

This commit is contained in:
Simon Knott 2025-02-19 09:33:29 +01:00
parent 4fb068e6ae
commit f759c1e83c
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 9 additions and 6 deletions

View file

@ -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;
}

View file

@ -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`);
});