chore: don't throw on no testDir (#11950)

This commit is contained in:
Pavel Feldman 2022-02-08 15:27:05 -08:00 committed by GitHub
parent d5158e8d24
commit 8dff2e35c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -218,11 +218,6 @@ export class Runner {
const files = new Map<ProjectImpl, string[]>();
for (const project of projects) {
const testDir = project.config.testDir;
if (!fs.existsSync(testDir))
throw new Error(`${testDir} does not exist`);
if (!fs.statSync(testDir).isDirectory())
throw new Error(`${testDir} is not a directory`);
const allFiles = await collectFiles(project.config.testDir);
const testMatch = createFileMatcher(project.config.testMatch);
const testIgnore = createFileMatcher(project.config.testIgnore);
@ -500,6 +495,11 @@ function filterSuite(suite: Suite, suiteFilter: (suites: Suite) => boolean, test
}
async function collectFiles(testDir: string): Promise<string[]> {
if (!fs.existsSync(testDir))
return [];
if (!fs.statSync(testDir).isDirectory())
return [];
type Rule = {
dir: string;
negate: boolean;

View file

@ -141,7 +141,7 @@ test('should exit with code 1 if the specified folder does not exist', async ({
`,
});
expect(result.exitCode).toBe(1);
expect(result.output).toContain(`111111111111.js does not exist`);
expect(result.output).toContain(`no tests found.`);
});
test('should exit with code 1 if passed a file name', async ({ runInlineTest }) => {
@ -153,7 +153,7 @@ test('should exit with code 1 if passed a file name', async ({ runInlineTest })
`,
});
expect(result.exitCode).toBe(1);
expect(result.output).toContain(`test.spec.js is not a directory`);
expect(result.output).toContain(`no tests found.`);
});
test('should exit with code 1 when config is not found', async ({ runInlineTest }) => {