fix(runner): filter args should respect trailing slash

This commit is contained in:
Simon Knott 2025-02-18 12:36:52 +01:00
parent 1af4e367f4
commit b3b7a7d224
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 26 additions and 1 deletions

View file

@ -159,7 +159,7 @@ export function mergeObjects<A extends object, B extends object, C extends objec
}
export function forceRegExp(pattern: string): RegExp {
const match = pattern.match(/^\/(.*)\/([gi]*)$/);
const match = pattern.match(/^\/(.*\/)([gi]*)$/);
if (match)
return new RegExp(match[1], match[2]);
return new RegExp(pattern, 'gi');

View file

@ -196,3 +196,28 @@ test('should focus a single test suite', async ({ runInlineTest }) => {
expect(result.report.suites[0].suites[0].suites[0].specs[0].title).toEqual('pass2');
expect(result.report.suites[0].suites[0].suites[0].specs[1].title).toEqual('pass3');
});
test('should filter by folder with absolute path', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/34813' } }, async ({ runInlineTest }) => {
const result = await runInlineTest({
'foo/x.spec.ts': `
import { test, expect } from '@playwright/test';
test('fails', () => { expect(1).toBe(2); });
`,
'foo/y.spec.ts': `
import { test, expect } from '@playwright/test';
test('fails', () => { expect(1).toBe(2); });
`,
'foobar/x.spec.ts': `
import { test, expect } from '@playwright/test';
test('fails', () => { expect(1).toBe(2); });
`,
'foobar/y.spec.ts': `
import { test, expect } from '@playwright/test';
test('fails', () => { expect(1).toBe(2); });
`,
}, undefined, undefined, { additionalArgs: [test.info().outputPath('foo') + '/'] });
expect(result.exitCode).toBe(1);
expect(result.failed).toBe(2);
expect(result.output).toMatch(/foo[\\/]x.spec.ts/);
expect(result.output).toMatch(/foo[\\/]y.spec.ts/);
});