Skip to content

[Bug]: Component tests fail when test files and components are deleted but remain in cache #37069

@shairez

Description

@shairez

Version

1.54.2

Steps to reproduce

  1. clone https://github.com/shairez/playwright-ct-crash-stale-cache-repro
  2. Run pnpm install
  3. Run pnpm test-ct to run the component tests.
  4. Delete the Child.test.tsx and Child.tsx files.
  5. Run pnpm test-ct to run the tests again.
  6. see the error.

Expected behavior

When test and component files are deleted, their cached component references should be automatically filtered out, and the remaining tests should run successfully without manual cache clearing.

Actual behavior

When using Playwright component testing, deleting test files and their associated components causes subsequent test runs to fail with "cannot find component" errors, even though the deleted components are no longer referenced by any existing tests.

This forces developers to manually run npx playwright clear-cache or clear the Playwright cache directory (playwright/.cache/) when components are deleted... which is no fun.

Additional context

In packages/playwright-ct-core/src/vitePlugin.ts, the checkNewComponents function blindly adds all old cached components back to the component registry without verifying that their source test files still exist.

I created a PR with the fix here #37069

Environment

System:
    OS: Linux 6.14 Ubuntu 25.04 25.04 (Plucky Puffin)
    CPU: (32) x64 AMD Ryzen 9 9950X 16-Core Processor
    Memory: 23.53 GB / 59.47 GB
    Container: Yes
  Binaries:
    Node: 22.14.0 - ~/.volta/tools/image/node/22.14.0/bin/node
    Yarn: 4.7.0 - ~/.volta/tools/image/yarn/4.7.0/bin/yarn
    npm: 10.9.2 - ~/.volta/tools/image/node/22.14.0/bin/npm
    pnpm: 10.6.3 - ~/.volta/bin/pnpm
  Languages:
    Bash: 5.2.37 - /usr/bin/bash
  npmPackages:
    @playwright/experimental-ct-react: ^1.54.2 => 1.55.0-next

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions