Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

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

Dmitry Gozman3739113e7424
diff --git a/src/test/util.ts b/src/test/util.ts
index 1b95349b43..98ec3acbb1 100644
--- a/src/test/util.ts
+++ b/src/test/util.ts
@@ -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;
diff --git a/tests/playwright-test/test-ignore.spec.ts b/tests/playwright-test/test-ignore.spec.ts
index 10021c2f54..e2ca689303 100644
--- a/tests/playwright-test/test-ignore.spec.ts
+++ b/tests/playwright-test/test-ignore.spec.ts
@@ -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);
+});