Skip to content

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

fix: respect .only in --list mode (#28721)

Yury Semikhatskydcaa5758f090
diff --git a/packages/playwright/src/runner/tasks.ts b/packages/playwright/src/runner/tasks.ts
index 7f874aef4e..7127f35ec2 100644
--- a/packages/playwright/src/runner/tasks.ts
+++ b/packages/playwright/src/runner/tasks.ts
@@ -102,7 +102,7 @@ function addRunTasks(taskRunner: TaskRunner<TestRun>, config: FullConfigInternal
export function createTaskRunnerForList(config: FullConfigInternal, reporter: ReporterV2, mode: 'in-process' | 'out-of-process', options: { failOnLoadErrors: boolean }): TaskRunner<TestRun> {
const taskRunner = new TaskRunner<TestRun>(reporter, config.config.globalTimeout);
- taskRunner.addTask('load tests', createLoadTask(mode, { ...options, filterOnly: false }));
+ taskRunner.addTask('load tests', createLoadTask(mode, { ...options, filterOnly: true }));
taskRunner.addTask('report begin', createReportBeginTask());
return taskRunner;
}
diff --git a/tests/playwright-test/list-mode.spec.ts b/tests/playwright-test/list-mode.spec.ts
index 1388b38dd9..80e21fd8f2 100644
--- a/tests/playwright-test/list-mode.spec.ts
+++ b/tests/playwright-test/list-mode.spec.ts
@@ -152,7 +152,8 @@ test('should report errors', async ({ runInlineTest }) => {
expect(result.output).toContain('> 3 | oh = 2;');
});
-test('should ignore .only', async ({ runInlineTest }) => {
+test('should respect .only', async ({ runInlineTest }) => {
+ test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/28709' });
const result = await runInlineTest({
'a.test.js': `
const { test, expect } = require('@playwright/test');
@@ -167,9 +168,8 @@ test('should ignore .only', async ({ runInlineTest }) => {
expect(result.exitCode).toBe(0);
expect(result.output).toContain([
`Listing tests:`,
- ` a.test.js:3:7 › example1`,
` a.test.js:6:12 › example2`,
- `Total: 2 tests in 1 file`
+ `Total: 1 test in 1 file`
].join('\n'));
});