fix(test-runner): case insensitive test filtering

This commit is contained in:
Joel Einbinder 2021-06-15 17:27:52 -07:00 committed by GitHub
parent 65777aebf6
commit 38e27c9c6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View file

@ -137,7 +137,7 @@ function forceRegExp(pattern: string): RegExp {
const match = pattern.match(/^\/(.*)\/([gi]*)$/);
if (match)
return new RegExp(match[1], match[2]);
return new RegExp(pattern, 'g');
return new RegExp(pattern, 'gi');
}
function overridesFromOptions(options: { [key: string]: any }): Config {

View file

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

View file

@ -211,6 +211,26 @@ test('should match regex string argument', async ({ runInlineTest }) => {
expect(result.exitCode).toBe(0);
});
test('should match case insensitive', async ({ runInlineTest }) => {
const result = await runInlineTest({
'capital/A.test.ts': `
const { test } = pwt;
test('pass', ({}) => {});
`,
'lowercase/a.test.ts': `
const { test } = pwt;
test('pass', ({}) => {});
`,
'b.test.ts': `
const { test } = pwt;
test('pass', ({}) => {});
`
}, { args: ['a.test.ts'] });
expect(result.passed).toBe(2);
expect(result.report.suites.map(s => s.file).sort()).toEqual(['capital/A.test.ts', 'lowercase/a.test.ts']);
expect(result.exitCode).toBe(0);
});
test('should match by directory', async ({ runInlineTest }) => {
const result = await runInlineTest({
'dir-a/file.test.ts': `