check file existance
This commit is contained in:
parent
cdd202fe98
commit
4fb068e6ae
|
|
@ -258,6 +258,8 @@ function validateConfig(file: string, config: Config) {
|
||||||
if ('tsconfig' in config && config.tsconfig !== undefined) {
|
if ('tsconfig' in config && config.tsconfig !== undefined) {
|
||||||
if (typeof config.tsconfig !== 'string')
|
if (typeof config.tsconfig !== 'string')
|
||||||
throw errorWithFile(file, `config.tsconfig must be a string`);
|
throw errorWithFile(file, `config.tsconfig must be a string`);
|
||||||
|
if (!fs.existsSync(path.resolve(file, '..', config.tsconfig)))
|
||||||
|
throw errorWithFile(file, `config.tsconfig does not exist`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -698,3 +698,35 @@ test('should merge ct configs', async ({ runInlineTest }) => {
|
||||||
});
|
});
|
||||||
expect(result.exitCode).toBe(0);
|
expect(result.exitCode).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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('should throw on nonexistant config.tsconfig', async ({ runInlineTest }) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'playwright.config.ts': `
|
||||||
|
export default {
|
||||||
|
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`);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -734,19 +734,6 @@ test('should respect config.tsconfig option', async ({ runInlineTest }) => {
|
||||||
expect(result.output).not.toContain(`Could not`);
|
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.describe('directory imports', () => {
|
||||||
test('should resolve index.js without path mapping in CJS', async ({ runInlineTest, runTSC }) => {
|
test('should resolve index.js without path mapping in CJS', async ({ runInlineTest, runTSC }) => {
|
||||||
const files = {
|
const files = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue