Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/playwright/src/runner/loadUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ export async function createRootSuite(testRun: TestRun, errors: TestError[], sho

// Filter file suites for all projects.
for (const [project, fileSuites] of testRun.projectSuites) {
projectSuites.set(project, createProjectSuite(project, fileSuites));

const filteredFileSuites = additionalFileMatcher ? fileSuites.filter(fileSuite => additionalFileMatcher(fileSuite.location!.file)) : fileSuites;
const projectSuite = createProjectSuite(project, filteredFileSuites);
projectSuites.set(project, projectSuite);
const filteredProjectSuite = filterProjectSuite(projectSuite, { cliFileFilters, cliTitleMatcher, testIdMatcher: config.testIdMatcher });
const filteredProjectSuite = filterProjectSuite(createProjectSuite(project, filteredFileSuites), { cliFileFilters, cliTitleMatcher, testIdMatcher: config.testIdMatcher });
filteredProjectSuites.set(project, filteredProjectSuite);
}
}
Expand Down Expand Up @@ -200,8 +200,8 @@ export async function createRootSuite(testRun: TestRun, errors: TestError[], sho
const projectClosure = new Map(buildProjectsClosure(rootSuite.suites.map(suite => suite._fullProject!)));

// Clone file suites for dependency projects.
for (const project of projectClosure.keys()) {
if (projectClosure.get(project) === 'dependency')
for (const [project, level] of projectClosure.entries()) {
if (level === 'dependency')
rootSuite._prependSuite(buildProjectSuite(project, projectSuites.get(project)!));
}
}
Expand Down
44 changes: 44 additions & 0 deletions tests/playwright-test/only-changed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,48 @@ test('UI mode is not supported', async ({ runInlineTest }) => {
const result = await runInlineTest({}, { 'only-changed': true, 'ui': true });
expect(result.exitCode).toBe(1);
expect(result.output).toContain('--only-changed is not supported in UI mode');
});

test('should run project dependencies of changed tests', async ({ runInlineTest, git, writeFiles }) => {
await writeFiles({
'playwright.config.ts': `
module.exports = {
projects: [
{ name: 'setup', testMatch: 'setup.spec.ts', },
{ name: 'main', dependencies: ['setup'] },
],
};
`,
'setup.spec.ts': `
import { test, expect } from '@playwright/test';

test('setup test', async ({ page }) => {
console.log('setup test is executed')
});
`,
'a.spec.ts': `
import { test, expect } from '@playwright/test';
test('fails', () => { expect(1).toBe(2); });
`,
'b.spec.ts': `
import { test, expect } from '@playwright/test';
test('fails', () => { expect(1).toBe(2); });
`,
});

git(`add .`);
git(`commit -m init`);

const result = await runInlineTest({
'c.spec.ts': `
import { test, expect } from '@playwright/test';
test('fails', () => { expect(1).toBe(2); });
`
}, { 'only-changed': true });

expect(result.exitCode).toBe(1);
expect(result.failed).toBe(1);
expect(result.passed).toBe(1);

expect(result.output).toContain('setup test is executed');
});
Loading