cherry-pick(#26503): chore: fix .only in dependent tests
This commit is contained in:
parent
0d5e6245ba
commit
4f2528535f
|
|
@ -117,7 +117,6 @@ export class WebServerPlugin implements TestRunnerPlugin {
|
||||||
this._reporter!.onStdErr?.(colors.dim('[WebServer] ') + line.toString());
|
this._reporter!.onStdErr?.(colors.dim('[WebServer] ') + line.toString());
|
||||||
});
|
});
|
||||||
launchedProcess.stdout!.on('data', line => {
|
launchedProcess.stdout!.on('data', line => {
|
||||||
process.stdout.write(line);
|
|
||||||
if (debugWebServer.enabled || this._options.stdout === 'pipe')
|
if (debugWebServer.enabled || this._options.stdout === 'pipe')
|
||||||
this._reporter!.onStdOut?.(colors.dim('[WebServer] ') + line.toString());
|
this._reporter!.onStdOut?.(colors.dim('[WebServer] ') + line.toString());
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,7 @@ export function buildProjectsClosure(projects: FullProjectInternal[], hasTests?:
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
const projectHasTests = hasTests ? hasTests(project) : true;
|
if (depth === 0 && hasTests && !hasTests(project))
|
||||||
if (!projectHasTests && depth === 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (result.get(project) !== 'dependency')
|
if (result.get(project) !== 'dependency')
|
||||||
|
|
|
||||||
|
|
@ -643,3 +643,50 @@ test('should not run deps for projects filtered with grep', async ({ runInlineTe
|
||||||
expect(result.passed).toBe(3);
|
expect(result.passed).toBe(3);
|
||||||
expect(result.outputLines).toEqual(['setupB', 'projectB', 'teardownB']);
|
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);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue