testing-library / user-event

🐕 Simulate user events
https://testing-library.com/user-event
MIT License
2.18k stars 246 forks source link

Invalid import from `@testing-library/dom` #1122

Open christian-bromann opened 1 year ago

christian-bromann commented 1 year ago

Reproduction example

I am working on this but it is hard to come up with one that is simple and useful for you.

Prerequisites

work in progress

Expected behavior

I can bundle @testing-library/user-event with Vite.

Actual behavior

In /src/utils/misc/getWindow.ts#L3 you are importing getWindowFromNode from @testing-library/dom. It seems like the compiler does some over optimisations which causes getWindow.ts to import from the CJS artifact of @testing-library/dom:

Screenshot 2023-04-25 at 22 16 32 (from NPM)

This is currently causing me headaches to support @testing-library/user-event in WebdriverIO component tests as it fails due to:

SyntaxError: The requested module '/node_modules/@testing-library/dom/dist/helpers.js?v=d5031d18' does not provide an export named 'getWindowFromNode'

Similar observations can be made for:

User-event version

latest

Environment

Testing Library framework:

JS framework:

Test environment:

DOM implementation:

Additional context

No response

onemen commented 1 year ago

I have similar issue when importing userEvent on ESM project ("type": "module") import userEvent from '@testing-library/user-event'

userEvent have no types

missing_types