Skip to content

Deep imports causing an error in @web/test-runner #1044

Closed
@remcovaes

Description

@remcovaes

Reproduction example

https://github.com/remcovaes/web-test-runer-with-user-event

Prerequisites

  1. Clone repo https://github.com/remcovaes/web-test-runer-with-user-event
  2. npm install
  3. You might have to initialize Playwright
  4. npm run test

Expected behavior

Working library

Actual behavior

the following error:
SyntaxError: The requested module './../../../../../dom/dist/helpers.js' does not provide an export named 'getWindowFromNode'

User-event version

14.4.3

Environment

Testing Library framework:

JS framework: none

Test environment:

DOM implementation: Running in a chromium

Additional context

See the file @testing-library/user-event/dist/esm/setup/setup.js and import import '@testing-library/dom/dist/helpers.js';.
This will work for commonjs as the file that is import using a deep import is commonjs. In the @web/test-runner, rollup and esbuild plugins are used to bundle (technically not actual plugins, but they work similar). Doing deep imports of commonjs files, throws the build of, causing the error as described above.

Possible fix is to remove all deep import from @testing-library/user-event and only import the stuff @testing-library/dom exposes via the main and module in the package.json. This will make sure that bundlers are able to pick the correct version.

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