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

Fixes https://github.com/microsoft/playwright/issues/26492
This commit is contained in:
Pavel Feldman 2023-08-16 13:39:08 -07:00 committed by GitHub
parent 1a1ff6c671
commit 929a849265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 3 deletions

View File

@ -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());
});

View File

@ -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')

View File

@ -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);
});