config validation

This commit is contained in:
Simon Knott 2025-02-19 09:12:31 +01:00
parent 0baadb513b
commit cdd202fe98
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 18 additions and 0 deletions

View file

@ -254,6 +254,11 @@ function validateConfig(file: string, config: Config) {
else if (typeof config.workers === 'string' && !config.workers.endsWith('%'))
throw errorWithFile(file, `config.workers must be a number or percentage`);
}
if ('tsconfig' in config && config.tsconfig !== undefined) {
if (typeof config.tsconfig !== 'string')
throw errorWithFile(file, `config.tsconfig must be a string`);
}
}
function validateProject(file: string, project: Project, title: string) {

View file

@ -734,6 +734,19 @@ test('should respect config.tsconfig option', async ({ runInlineTest }) => {
expect(result.output).not.toContain(`Could not`);
});
test('should throw on invalid config.tsconfig option', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
export default {
tsconfig: true,
};
`,
});
expect(result.exitCode).toBe(1);
expect(result.output).toContain(`config.tsconfig must be a string`);
});
test.describe('directory imports', () => {
test('should resolve index.js without path mapping in CJS', async ({ runInlineTest, runTSC }) => {
const files = {