testing-library / vue-testing-library

🦎 Simple and complete Vue.js testing utilities that encourage good testing practices.
http://testing-library.com/vue
MIT License
1.08k stars 109 forks source link

ESM export #292

Open christian-bromann opened 1 year ago

christian-bromann commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

This is less a bug as a feature request. It would be great if this package could export an ESM bundle. I am maintaining the WebdriverIO project and we are recommending this library for component testing in the browser. We have Vite transforming the CJS code into ESM but it fails doing that for Windows for whatever reasons.

I thought exporting an ESM version is a reasonable request and would make adopters life a bit easier.

Happy to take a stab at it.

To Reproduce Steps to reproduce the behavior:

Try to import this package within a ESM context.

Expected behavior

It should load.

Screenshots

Related information:

Relevant code or config (if any)

Additional context

sheremet-va commented 6 months ago

On the Vitest side, we are very interested in having this implemented. Importing @testing-library/vue in Vite incorrectly imports UMD build of @vue/test-utils because it uses the browser condition and bypasses the import one - not sure if it's the bug in Vite or it's supposed to prioritise require condition if require() was used (like in this package).

I will try to prepare a PR when I have more time.