chore: don't throw on no testDir (#11950)
This commit is contained in:
parent
d5158e8d24
commit
8dff2e35c8
|
|
@ -218,11 +218,6 @@ export class Runner {
|
||||||
|
|
||||||
const files = new Map<ProjectImpl, string[]>();
|
const files = new Map<ProjectImpl, string[]>();
|
||||||
for (const project of projects) {
|
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 allFiles = await collectFiles(project.config.testDir);
|
||||||
const testMatch = createFileMatcher(project.config.testMatch);
|
const testMatch = createFileMatcher(project.config.testMatch);
|
||||||
const testIgnore = createFileMatcher(project.config.testIgnore);
|
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[]> {
|
async function collectFiles(testDir: string): Promise<string[]> {
|
||||||
|
if (!fs.existsSync(testDir))
|
||||||
|
return [];
|
||||||
|
if (!fs.statSync(testDir).isDirectory())
|
||||||
|
return [];
|
||||||
|
|
||||||
type Rule = {
|
type Rule = {
|
||||||
dir: string;
|
dir: string;
|
||||||
negate: boolean;
|
negate: boolean;
|
||||||
|
|
|
||||||
|
|
@ -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.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 }) => {
|
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.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 }) => {
|
test('should exit with code 1 when config is not found', async ({ runInlineTest }) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue