fix(test runner): allow dot-files and dot-directories with tests (#8751)

This commit is contained in:
Dmitry Gozman 2021-09-07 10:32:47 -07:00 committed by GitHub
parent e914f6bbc7
commit 3739113e74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 3 deletions

View file

@ -112,9 +112,7 @@ export function createMatcher(patterns: string | RegExp | (string | RegExp)[]):
return true;
}
for (const pattern of filePatterns) {
if (minimatch(value, pattern, {
nocase: true,
}))
if (minimatch(value, pattern, { nocase: true, dot: true }))
return true;
}
return false;

View file

@ -390,3 +390,31 @@ test('should only match files with JS/TS file extensions', async ({ runInlineTes
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(2);
});
test('should match dot-files', async ({ runInlineTest }) => {
const result = await runInlineTest({
'.a.test.ts': `
const { test } = pwt;
test('pass', ({}) => {});
`,
});
expect(result.passed).toBe(1);
expect(result.report.suites.map(s => s.file).sort()).toEqual(['.a.test.ts']);
expect(result.exitCode).toBe(0);
});
test('should match in dot-directories', async ({ runInlineTest }) => {
const result = await runInlineTest({
'.dir/a.test.ts': `
const { test } = pwt;
test('pass', ({}) => {});
`,
'.dir/b.test.js': `
const { test } = pwt;
test('pass', ({}) => {});
`,
});
expect(result.passed).toBe(2);
expect(result.report.suites.map(s => s.file).sort()).toEqual(['.dir/a.test.ts', '.dir/b.test.js']);
expect(result.exitCode).toBe(0);
});