Skip to content

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

chore: fix .only in dependent tests (#26503)

Pavel Feldman929a84926563
diff --git a/packages/playwright-test/src/plugins/webServerPlugin.ts b/packages/playwright-test/src/plugins/webServerPlugin.ts
index 84ba892c53..c45273108d 100644
--- a/packages/playwright-test/src/plugins/webServerPlugin.ts
+++ b/packages/playwright-test/src/plugins/webServerPlugin.ts
@@ -116,7 +116,6 @@ export class WebServerPlugin implements TestRunnerPlugin {
this._reporter!.onStdErr?.(colors.dim('[WebServer] ') + line.toString());
});
launchedProcess.stdout!.on('data', line => {
- process.stdout.write(line);
if (debugWebServer.enabled || this._options.stdout === 'pipe')
this._reporter!.onStdOut?.(colors.dim('[WebServer] ') + line.toString());
});
diff --git a/packages/playwright-test/src/runner/projectUtils.ts b/packages/playwright-test/src/runner/projectUtils.ts
index b0af7ffeb4..4469be3744 100644
--- a/packages/playwright-test/src/runner/projectUtils.ts
+++ b/packages/playwright-test/src/runner/projectUtils.ts
@@ -70,8 +70,7 @@ export function buildProjectsClosure(projects: FullProjectInternal[], hasTests?:
throw error;
}
- const projectHasTests = hasTests ? hasTests(project) : true;
- if (!projectHasTests && depth === 0)
+ if (depth === 0 && hasTests && !hasTests(project))
return;
if (result.get(project) !== 'dependency')
diff --git a/tests/playwright-test/deps.spec.ts b/tests/playwright-test/deps.spec.ts
index 4e97cb4d09..f2a4852c70 100644
--- a/tests/playwright-test/deps.spec.ts
+++ b/tests/playwright-test/deps.spec.ts
@@ -643,3 +643,50 @@ test('should not run deps for projects filtered with grep', async ({ runInlineTe
expect(result.passed).toBe(3);
expect(result.outputLines).toEqual(['setupB', 'projectB', 'teardownB']);
});
+
+test('should allow only in dependent', async ({ runInlineTest }) => {
+ const result = await runInlineTest({
+ 'playwright.config.ts': `
+ module.exports = {
+ projects: [
+ { name: 'setup', testMatch: '**/setup.ts' },
+ { name: 'project', dependencies: ['setup'] },
+ ],
+ };`,
+ 'setup.ts': `
+ import { test, expect } from '@playwright/test';
+ test('setup', async ({}) => {});
+ `,
+ 'a.spec.ts': `
+ import { test, expect } from '@playwright/test';
+ test.only('test', async ({}) => {
+ });
+ test('test 2', async ({}) => { expect(1).toBe(2); });
+ `,
+ });
+ expect(result.exitCode).toBe(0);
+ expect(result.passed).toBe(2);
+});
+
+test('should allow only in dependent (2)', async ({ runInlineTest }) => {
+ const result = await runInlineTest({
+ 'playwright.config.ts': `
+ module.exports = {
+ projects: [
+ { name: 'setup', testMatch: '**/setup.ts' },
+ { name: 'project', dependencies: ['setup'] },
+ ],
+ };`,
+ 'setup.ts': `
+ import { test, expect } from '@playwright/test';
+ test.only('setup', async ({}) => {});
+ `,
+ 'a.spec.ts': `
+ import { test, expect } from '@playwright/test';
+ test('test', async ({}) => { expect(1).toBe(2); });
+ test('test 2', async ({}) => { expect(1).toBe(2); });
+ `,
+ });
+ expect(result.exitCode).toBe(0);
+ expect(result.passed).toBe(1);
+});