|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 | 16 |
|
17 |
| -import { test, expect, playwrightCtConfigText } from './playwright-test-fixtures'; |
18 | 17 | import fs from 'fs';
|
19 | 18 | import path from 'path';
|
| 19 | +import { expect, playwrightCtConfigText, test } from './playwright-test-fixtures'; |
20 | 20 |
|
21 | 21 | test.describe.configure({ mode: 'parallel' });
|
22 | 22 |
|
@@ -351,6 +351,55 @@ test('should grow cache', async ({ runInlineTest }, testInfo) => {
|
351 | 351 | });
|
352 | 352 | });
|
353 | 353 |
|
| 354 | +test('should not crash when cached component test file is deleted', async ({ runInlineTest }, testInfo) => { |
| 355 | + |
| 356 | + await test.step('run first test to build the cache', async () => { |
| 357 | + const result = await runInlineTest({ |
| 358 | + 'playwright.config.ts': playwrightCtConfigText, |
| 359 | + 'playwright/index.html': `<script type="module" src="./index.ts"></script>`, |
| 360 | + 'playwright/index.ts': ``, |
| 361 | + 'src/button.tsx': ` |
| 362 | + export const Button = () => <button>Button</button>; |
| 363 | + `, |
| 364 | + 'src/button.test.tsx': ` |
| 365 | + import { test, expect } from '@playwright/experimental-ct-react'; |
| 366 | + import { Button } from './button.tsx'; |
| 367 | + test('pass', async ({ mount }) => { |
| 368 | + const component = await mount(<Button></Button>); |
| 369 | + await expect(component).toHaveText('Button'); |
| 370 | + }); |
| 371 | + `, |
| 372 | + 'src/button2.tsx': ` |
| 373 | + export const Button2 = () => <button>Button 2</button>; |
| 374 | + `, |
| 375 | + 'src/button2.test.tsx': ` |
| 376 | + import { test, expect } from '@playwright/experimental-ct-react'; |
| 377 | + import { Button2 } from './button2.tsx'; |
| 378 | + test('pass', async ({ mount }) => { |
| 379 | + const component = await mount(<Button2></Button2>); |
| 380 | + await expect(component).toHaveText('Button 2'); |
| 381 | + }); |
| 382 | + `, |
| 383 | + }, { workers: 1 }); |
| 384 | + |
| 385 | + expect(result.exitCode).toBe(0); |
| 386 | + expect(result.passed).toBe(2); |
| 387 | + |
| 388 | + }); |
| 389 | + |
| 390 | + await test.step('remove the second test and component and run the tests again', async () => { |
| 391 | + |
| 392 | + fs.unlinkSync(testInfo.outputPath('src/button2.tsx')); |
| 393 | + fs.unlinkSync(testInfo.outputPath('src/button2.test.tsx')); |
| 394 | + |
| 395 | + const result2 = await runInlineTest({}, { workers: 1 }); |
| 396 | + |
| 397 | + expect(result2.exitCode).toBe(0); |
| 398 | + expect(result2.passed).toBe(1); |
| 399 | + }); |
| 400 | + |
| 401 | +}); |
| 402 | + |
354 | 403 | test('should not use global config for preview', async ({ runInlineTest }) => {
|
355 | 404 | const result1 = await runInlineTest({
|
356 | 405 | 'playwright.config.ts': playwrightCtConfigText,
|
|
0 commit comments