Skip to content

[Bug]: Component tests fails when imported a module with a dot in a name #29739

@chekrd

Description

@chekrd

Version

^1.41.1

Steps to reproduce

  1. Clone my repro repo https://github.com/chekrd/pw-import-bug/tree/master
  2. npm ci
  3. npm run playwright

Expected behavior

The project is compiled and the test is OK.

Actual behavior

Module named "Component.uitest.shared.ts" is converted to {"__pw_type": "importRef", "id": "__Component_uitest_shared_componentMock", "property": "content"} and the runtime is broken.

Any module with a "." in its name, imported into the .uitest.tsx (a script running in NodeJs PW test runtime) is affected.

Additional context

Up to the version 1.41.0 it worked as expected.

Related issue without resolution (the fix was applied, issue closed and later the fix commit was reverted): #29302

Naming modules with aditional context in its name using a dot as a separator is common practice in JS ecosystem. Even Playwright itself uses *.spec.ts(x) as a default.

Environment

System:
    OS: macOS 14.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 82.22 MB / 16.00 GB
  Binaries:
    Node: 21.6.2 - ~/.nvm/versions/node/v21.6.2/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v21.6.2/bin/npm
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/experimental-ct-react: 1.42.0 => 1.42.0
    @playwright/test: 1.42.0 => 1.42.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions