Description
@testing-library/react
version: latest- Testing Framework and version: n/a
- DOM Environment: n/a
Relevant code or config:
https://github.com/testing-library/react-testing-library/blob/master/src/pure.js#L118-L120
// just re-export everything from dom-testing-library
export * from '@testing-library/dom'
export {render, cleanup, act, fireEvent}
What you did:
Bundled this package with Rollup via Snowpack.
What happened:
[snowpack] Conflicting namespaces: ../../node_modules/@testing-library/react/dist/@testing-library/react.esm.js re-exports 'fireEvent' from both ../../node_modules/@testing-library/react/dist/@testing-library/react.esm.js and ../../node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js (will be ignored)
Problem description:
fireEvent
is exported twice out of the @testing-library/react
package: once directly, and then once indirectly via an export *
invocation (see link above). This is invalid ESM that will break in pure ESM environments (ex: Node) and create warnings in others (Snowpack, Rollup, etc). See convo below.
Suggested solution:
Ref: https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export
- Stop re-exporting @testing-library/dom, let the user import things out of this package themselves as needed.
- re-export an explicit set of named exports. Harder to maintain.
- export the custom package
fireEvent
function asfireReactEvent
instead, preventing conflict.