From c395177f5d829d2f91473d244fdb1a02bff35c3e Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Tue, 22 Nov 2022 00:12:47 +0530 Subject: [PATCH] fix: detect tests in folders starting with `.` (fix #2344) (#2359) * fix(core): Enable `dot` in globOptions * test(core): Add test for files in `.` folders. * test(core): Fix test for files in `.` folders. --- packages/vitest/src/node/core.ts | 3 ++- test/fails/fixtures/.dot-folder/dot-test.test.ts | 5 +++++ test/fails/test/__snapshots__/runner.test.ts.snap | 2 ++ test/fails/test/runner.test.ts | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 test/fails/fixtures/.dot-folder/dot-test.test.ts diff --git a/packages/vitest/src/node/core.ts b/packages/vitest/src/node/core.ts index c6d276ed1812..cb57de591df9 100644 --- a/packages/vitest/src/node/core.ts +++ b/packages/vitest/src/node/core.ts @@ -553,8 +553,9 @@ export class Vitest { async globTestFiles(filters: string[] = []) { const { include, exclude, includeSource } = this.config - const globOptions = { + const globOptions: fg.Options = { absolute: true, + dot: true, cwd: this.config.dir || this.config.root, ignore: exclude, } diff --git a/test/fails/fixtures/.dot-folder/dot-test.test.ts b/test/fails/fixtures/.dot-folder/dot-test.test.ts new file mode 100644 index 000000000000..cc87e2c7a49d --- /dev/null +++ b/test/fails/fixtures/.dot-folder/dot-test.test.ts @@ -0,0 +1,5 @@ +import { expect, test } from 'vitest' + +test('check that tests inside folder with . is run', () => { + expect(true).toBe(false) +}) diff --git a/test/fails/test/__snapshots__/runner.test.ts.snap b/test/fails/test/__snapshots__/runner.test.ts.snap index 57239f2dd6ec..8b0e88a42561 100644 --- a/test/fails/test/__snapshots__/runner.test.ts.snap +++ b/test/fails/test/__snapshots__/runner.test.ts.snap @@ -1,5 +1,7 @@ // Vitest Snapshot v1 +exports[`should fails > .dot-folder/dot-test.test.ts > .dot-folder/dot-test.test.ts 1`] = `"AssertionError: expected true to be false // Object.is equality"`; + exports[`should fails > each-timeout.test.ts > each-timeout.test.ts 1`] = `"Error: Test timed out in 10ms."`; exports[`should fails > empty.test.ts > empty.test.ts 1`] = `"Error: No test suite found in file /empty.test.ts"`; diff --git a/test/fails/test/runner.test.ts b/test/fails/test/runner.test.ts index 20e732c3c744..8965f7ca0a60 100644 --- a/test/fails/test/runner.test.ts +++ b/test/fails/test/runner.test.ts @@ -5,7 +5,7 @@ import { describe, expect, it } from 'vitest' describe('should fails', async () => { const root = resolve(__dirname, '../fixtures') - const files = await fg('*.test.ts', { cwd: root }) + const files = await fg('**/*.test.ts', { cwd: root, dot: true }) for (const file of files) { it(file, async () => {