Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/playwright/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import fs from 'fs';
import path from 'path';
import url from 'url';
import util from 'util';

import debug from 'debug';
Expand Down Expand Up @@ -114,12 +113,12 @@ export function createFileMatcher(patterns: string | RegExp | (string | RegExp)[
return true;
}
// Windows might still receive unix style paths from Cygwin or Git Bash.
// Check against the file url as well.
// Check against the forward-slash form as well.
if (path.sep === '\\') {
const fileURL = url.pathToFileURL(filePath).href;
const unixPath = filePath.split(path.sep).join('/');
for (const re of reList) {
re.lastIndex = 0;
if (re.test(fileURL))
if (re.test(unixPath))
return true;
}
}
Expand Down
17 changes: 17 additions & 0 deletions tests/playwright-test/command-line-filter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,23 @@ test('should focus a single nested test spec', async ({ runInlineTest }) => {
expect(result.report.suites[1].suites[0].suites[0].specs[0].title).toEqual('pass2');
});

test('should accept unix file path containing a space', async ({ runInlineTest }) => {
const result = await runInlineTest({
'dir with space/a.spec.ts': `
import { test, expect } from '@playwright/test';
test('passes', () => { expect(1).toBe(1); });
`,
'dir with space/b.spec.ts': `
import { test, expect } from '@playwright/test';
test('not picked', () => { expect(1).toBe(2); });
`,
}, undefined, undefined, { additionalArgs: ['dir with space/a.spec.ts'] });
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
expect(result.report.suites).toHaveLength(1);
expect(result.report.suites[0].specs[0].title).toBe('passes');
});

test('should focus a single test suite', async ({ runInlineTest }) => {
const result = await runInlineTest({
'foo.test.ts': `
Expand Down
Loading