Skip to content

Commit c395177

Browse files
authoredNov 21, 2022
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.
1 parent f7b27af commit c395177

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed
 

‎packages/vitest/src/node/core.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,9 @@ export class Vitest {
553553
async globTestFiles(filters: string[] = []) {
554554
const { include, exclude, includeSource } = this.config
555555

556-
const globOptions = {
556+
const globOptions: fg.Options = {
557557
absolute: true,
558+
dot: true,
558559
cwd: this.config.dir || this.config.root,
559560
ignore: exclude,
560561
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { expect, test } from 'vitest'
2+
3+
test('check that tests inside folder with . is run', () => {
4+
expect(true).toBe(false)
5+
})

‎test/fails/test/__snapshots__/runner.test.ts.snap

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Vitest Snapshot v1
22

3+
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"`;
4+
35
exports[`should fails > each-timeout.test.ts > each-timeout.test.ts 1`] = `"Error: Test timed out in 10ms."`;
46

57
exports[`should fails > empty.test.ts > empty.test.ts 1`] = `"Error: No test suite found in file <rootDir>/empty.test.ts"`;

‎test/fails/test/runner.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { describe, expect, it } from 'vitest'
55

66
describe('should fails', async () => {
77
const root = resolve(__dirname, '../fixtures')
8-
const files = await fg('*.test.ts', { cwd: root })
8+
const files = await fg('**/*.test.ts', { cwd: root, dot: true })
99

1010
for (const file of files) {
1111
it(file, async () => {

0 commit comments

Comments
 (0)
Please sign in to comment.