fix(test runner): always show all projects in selection (#32450)
Follow-up to https://github.com/microsoft/playwright/pull/32156#discussion_r1741628770, alternative solution to https://github.com/microsoft/playwright/pull/32425. Ensures we always show all projects in the watch mode project selector by performing the initial `listTests` without any filters, and using its result for the project selector.
This commit is contained in:
parent
a8f67a42b8
commit
0e3f4736cc
|
|
@ -125,9 +125,11 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
await testServerConnection.initialize({ interceptStdio: false, watchTestDirs: true });
|
await testServerConnection.initialize({ interceptStdio: false, watchTestDirs: true });
|
||||||
await testServerConnection.runGlobalSetup({});
|
await testServerConnection.runGlobalSetup({});
|
||||||
|
|
||||||
const { report } = await testServerConnection.listTests({ locations: options.files, projects: options.projects, grep: options.grep });
|
const { report } = await testServerConnection.listTests({});
|
||||||
teleSuiteUpdater.processListReport(report);
|
teleSuiteUpdater.processListReport(report);
|
||||||
|
|
||||||
|
const projectNames = teleSuiteUpdater.rootSuite!.suites.map(s => s.title);
|
||||||
|
|
||||||
let lastRun: { type: 'changed' | 'regular' | 'failed', failedTestIds?: string[], dirtyTestIds?: string[] } = { type: 'regular' };
|
let lastRun: { type: 'changed' | 'regular' | 'failed', failedTestIds?: string[], dirtyTestIds?: string[] } = { type: 'regular' };
|
||||||
let result: FullResult['status'] = 'passed';
|
let result: FullResult['status'] = 'passed';
|
||||||
|
|
||||||
|
|
@ -167,7 +169,7 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
||||||
type: 'multiselect',
|
type: 'multiselect',
|
||||||
name: 'selectedProjects',
|
name: 'selectedProjects',
|
||||||
message: 'Select projects',
|
message: 'Select projects',
|
||||||
choices: teleSuiteUpdater.rootSuite!.suites.map(s => s.title),
|
choices: projectNames,
|
||||||
}).catch(() => ({ selectedProjects: null }));
|
}).catch(() => ({ selectedProjects: null }));
|
||||||
if (!selectedProjects)
|
if (!selectedProjects)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -282,8 +282,8 @@ test('should respect file filter P', async ({ runWatchTest }) => {
|
||||||
await testProcess.waitForOutput('Waiting for file changes.');
|
await testProcess.waitForOutput('Waiting for file changes.');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should respect project filter C', async ({ runWatchTest }) => {
|
test('should respect project filter C', async ({ runWatchTest, writeFiles }) => {
|
||||||
const testProcess = await runWatchTest({
|
const files = {
|
||||||
'playwright.config.ts': `
|
'playwright.config.ts': `
|
||||||
import { defineConfig } from '@playwright/test';
|
import { defineConfig } from '@playwright/test';
|
||||||
export default defineConfig({ projects: [{name: 'foo'}, {name: 'bar'}] });
|
export default defineConfig({ projects: [{name: 'foo'}, {name: 'bar'}] });
|
||||||
|
|
@ -292,9 +292,9 @@ test('should respect project filter C', async ({ runWatchTest }) => {
|
||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
test('passes', () => {});
|
test('passes', () => {});
|
||||||
`,
|
`,
|
||||||
});
|
};
|
||||||
|
const testProcess = await runWatchTest(files, { project: 'foo' });
|
||||||
await testProcess.waitForOutput('[foo] › a.test.ts:3:11 › passes');
|
await testProcess.waitForOutput('[foo] › a.test.ts:3:11 › passes');
|
||||||
await testProcess.waitForOutput('[bar] › a.test.ts:3:11 › passes');
|
|
||||||
await testProcess.waitForOutput('Waiting for file changes.');
|
await testProcess.waitForOutput('Waiting for file changes.');
|
||||||
testProcess.clearOutput();
|
testProcess.clearOutput();
|
||||||
testProcess.write('c');
|
testProcess.write('c');
|
||||||
|
|
@ -306,6 +306,16 @@ test('should respect project filter C', async ({ runWatchTest }) => {
|
||||||
await testProcess.waitForOutput('npx playwright test --project foo #1');
|
await testProcess.waitForOutput('npx playwright test --project foo #1');
|
||||||
await testProcess.waitForOutput('[foo] › a.test.ts:3:11 › passes');
|
await testProcess.waitForOutput('[foo] › a.test.ts:3:11 › passes');
|
||||||
expect(testProcess.output).not.toContain('[bar] › a.test.ts:3:11 › passes');
|
expect(testProcess.output).not.toContain('[bar] › a.test.ts:3:11 › passes');
|
||||||
|
|
||||||
|
testProcess.clearOutput();
|
||||||
|
|
||||||
|
await writeFiles(files); // file change triggers listTests with project filter
|
||||||
|
await testProcess.waitForOutput('[foo] › a.test.ts:3:11 › passes');
|
||||||
|
|
||||||
|
testProcess.write('c');
|
||||||
|
await testProcess.waitForOutput('Select projects');
|
||||||
|
await testProcess.waitForOutput('foo');
|
||||||
|
await testProcess.waitForOutput('bar'); // second selection should still show all
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should respect file filter P and split files', async ({ runWatchTest }) => {
|
test('should respect file filter P and split files', async ({ runWatchTest }) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue