diff --git a/packages/playwright-ct-core/src/vitePlugin.ts b/packages/playwright-ct-core/src/vitePlugin.ts index 9cebabc56c..5e9f607cb1 100644 --- a/packages/playwright-ct-core/src/vitePlugin.ts +++ b/packages/playwright-ct-core/src/vitePlugin.ts @@ -173,7 +173,12 @@ export async function buildBundle(config: FullConfig, configDir: string): Promis { for (const [importingFile, components] of componentsByImportingFile) { - setExternalDependencies(importingFile, components) + const deps = new Set(); + for (const component of components) { + for (const d of buildInfo.deps[component]) + deps.add(d); + } + setExternalDependencies(importingFile, [...deps]); } } diff --git a/tests/playwright-test/only-changed.spec.ts b/tests/playwright-test/only-changed.spec.ts index b67aa912cc..ca02c5a067 100644 --- a/tests/playwright-test/only-changed.spec.ts +++ b/tests/playwright-test/only-changed.spec.ts @@ -152,8 +152,12 @@ test('should suppport component tests', async ({ runInlineTest, setupRepository, 'playwright/index.html': ``, 'playwright/index.ts': ` `, + 'src/contents.ts': ` + export const content = "Button"; + `, 'src/button.tsx': ` - export const Button = () => ; + import {content} from './contents'; + export const Button = () => ; `, 'src/button.test.tsx': ` import { test, expect } from '@playwright/experimental-ct-react'; @@ -204,8 +208,8 @@ test('should suppport component tests', async ({ runInlineTest, setupRepository, git('commit -am "update button2 test"'); const result3 = await runInlineTest({ - 'src/button.tsx': ` - export const Button = () => ; + 'src/contents.ts': ` + export const content = 'Changed Content'; ` }, { 'workers': 1, 'only-changed': true });