fix(test-runner): do only match JS/TS files when collecting (#7014)

This commit is contained in:
Max Schmitt 2021-06-10 07:41:57 -07:00 committed by GitHub
parent 144ef2a72d
commit 05382c997b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

@ -143,7 +143,8 @@ export class Runner {
const allFiles = await collectFiles(project.config.testDir);
const testMatch = createMatcher(project.config.testMatch);
const testIgnore = createMatcher(project.config.testIgnore);
const testFiles = allFiles.filter(file => !testIgnore(file) && testMatch(file) && testFileFilter(file));
const testFileExtension = (file: string) => ['.js', '.ts'].includes(path.extname(file));
const testFiles = allFiles.filter(file => !testIgnore(file) && testMatch(file) && testFileFilter(file) && testFileExtension(file));
files.set(project, testFiles);
testFiles.forEach(file => allTestFiles.add(file));
}

View File

@ -259,4 +259,25 @@ test('should ignore node_modules even with custom testIgnore', async ({ runInlin
});
expect(result.passed).toBe(1);
expect(result.exitCode).toBe(0);
});
});
test('should only match files with JS/TS file extensions', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = { testMatch: /foobar/ };
`,
'foobar.test.ts': `
const { test } = pwt;
test('pass', ({}) => {});
`,
'foobar.test.js': `
const { test } = pwt;
test('pass', ({}) => {});
`,
'foobar.test.ts-snapshots/compares-page-screenshot-chromium-linux-test-chromium.png': `
<S0MeTh1ngN0nPArsAble!
`
});
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(2);
});