jest-dom icon indicating copy to clipboard operation
jest-dom copied to clipboard

Make UMD Distro Available

Open Smolations opened this issue 4 years ago • 4 comments

Describe the feature you'd like:

This should be a fairly short and sweet conversation (and possibly related to #201). I am a developer working on a fairly complex enterprise app. This app has pages with tons of form fields. While developing new features, I found myself filling out the same fields with the same values over and over again. To remedy this, I thought it would be a time saver to automate the process with chrome snippets and some "page model" classes. To normalize the architecture and encourage good testing practices, I wanted to run jest tests in the browser. This also has the benefit of giving me insight into what selectors our QA engineers would need when writing their automation tests.

Sadly, Jest is not available in the browser, but jest-lite is! So then I set out to look at RTL CDN sources and discovered that not all are available. I was lucky to find a UMD export for @testing-library/dom, but was saddened to find no equivalent support for two other useful libs: jest-dom and user-event.

I haven't spent a ton of time reading the code of each to find out if there are node deps preventing such a UMD generation, so I figured opening a quick issue would be the fastest route to find out. So my feature request (or question) is:

Can a jest-dom.umd.min.js be added to jest-dom/dist?

Also, if jest-dom doesn't qualify, is the user-event lib disqualified for the same reason?

Suggested implementation:

Include a minified UMD as a dist/ file when building the package.

Describe alternatives you've considered:

  • Maintaining my own version (if possible) by re-packing the distro (ain't nobody got time for that)
  • Writing my own matchers (no way! 😂 )

Teachability, Documentation, Adoption, Migration Strategy:

None necessary. No docs for the the other package's UMD distro. Users use at their discretion.

Smolations avatar Sep 15 '21 20:09 Smolations

I'm not entirely sure if this makes any sense, but maybe this works?

https://unpkg.com/browse/@testing-library/[email protected]/dist/

gnapse avatar Sep 19 '21 02:09 gnapse

@gnapse If you visit the package details (via your link) and look at the module file (among others) you'll see require statements, as well as references to exports. These are not natively supported by the browser. Trust me, I tried! 😅

Smolations avatar Sep 20 '21 21:09 Smolations

Ok, let's do this. Though, TBH, I'm not sure that I can jump on it right now. Would you be able to take a crack at it?

gnapse avatar Sep 20 '21 21:09 gnapse

Mayhap @gnapse . Mayhap. 😎 😏

Smolations avatar Sep 24 '21 23:09 Smolations