diff --git a/tests/playwright-test/only-changed.spec.ts b/tests/playwright-test/only-changed.spec.ts index 45b750cbe4..bfd359e309 100644 --- a/tests/playwright-test/only-changed.spec.ts +++ b/tests/playwright-test/only-changed.spec.ts @@ -364,4 +364,46 @@ 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.ts', }, + { name: 'main', dependencies: ['setup'] }, + ], + }; + `, + 'setup.ts': ` + console.log("setup is run") + `, + '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(0); + + console.log(result.output); + expect(result.output).toContain('setup is run'); + expect(result.output).toContain('c.spec.ts'); }); \ No newline at end of file