React-testing-library: Ship UMD build

Created on 29 Jun 2018  路  3Comments  路  Source: testing-library/react-testing-library

Describe the feature you'd like:

It would be awesome if there was a umd build so that this could be used with something like QUnit which is run in the browser. This way the lib could be included via a script tag either downloaded or with unpkg and be ready to use in environments without module loading.

This might make more sense over in the dom-testing-library repo, but I'm putting it here since the intended use is with react.

Suggested implementation:


Similar to React or other libs that export umd builds, it would mean exporting exporting a global like ReactTestingLib or maybe something shorter (open to suggestions).

P.S. I can work on a PR for this feature. Seems like it would be fun.

Describe alternatives you've considered:


Switch test runners (big effort).

Teachability, Documentation, Adoption, Migration Strategy:

Build example of using this in an environment with no module loading. Purely script tags in a page.

released

Most helpful comment

Well, there's a UMD build for dom-testing-library now, but I'm struggling to get react-dom/test-utils to build with the UMD bundle of react-testing-library. I'd like to drop that dependency anyway though so I'm looking at ways to do that. I'm feeling pretty good about my progress, but there are still some complications and things that need to be worked out thanks to how react does things with events. Hopefully when we can drop the Simulate dependency entirely though we'll be able to have a good UMD build :)

All 3 comments

We can definitely do this. kcd-scripts build supports this via a --bundle flag. I think that'd probably be fine because people should be requiring the commonjs files directly anyway. Let me give this a shot...

Well, there's a UMD build for dom-testing-library now, but I'm struggling to get react-dom/test-utils to build with the UMD bundle of react-testing-library. I'd like to drop that dependency anyway though so I'm looking at ways to do that. I'm feeling pretty good about my progress, but there are still some complications and things that need to be worked out thanks to how react does things with events. Hopefully when we can drop the Simulate dependency entirely though we'll be able to have a good UMD build :)

:tada: This issue has been resolved in version 5.2.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings