From 8dff2e35c867367f640a27736d89630b623de603 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Tue, 8 Feb 2022 15:27:05 -0800 Subject: [PATCH] chore: don't throw on no testDir (#11950) --- packages/playwright-test/src/runner.ts | 10 +++++----- tests/playwright-test/exit-code.spec.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/playwright-test/src/runner.ts b/packages/playwright-test/src/runner.ts index 8d7a6ef99a..f1bab7a8d2 100644 --- a/packages/playwright-test/src/runner.ts +++ b/packages/playwright-test/src/runner.ts @@ -218,11 +218,6 @@ export class Runner { const files = new Map(); 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 { + if (!fs.existsSync(testDir)) + return []; + if (!fs.statSync(testDir).isDirectory()) + return []; + type Rule = { dir: string; negate: boolean; diff --git a/tests/playwright-test/exit-code.spec.ts b/tests/playwright-test/exit-code.spec.ts index 7c7577e26e..eac2c8a963 100644 --- a/tests/playwright-test/exit-code.spec.ts +++ b/tests/playwright-test/exit-code.spec.ts @@ -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 }) => {