Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: UMD version of react-test-renderer #12572

Closed
srb101 opened this issue Apr 8, 2018 · 6 comments
Closed

Feature Request: UMD version of react-test-renderer #12572

srb101 opened this issue Apr 8, 2018 · 6 comments
Assignees

Comments

@srb101
Copy link

srb101 commented Apr 8, 2018

react and react-dom have both cjs and umd versions available.

Is it possible to create a umd version of react-test-renderer as well?

@bvaughn
Copy link
Contributor

bvaughn commented Apr 10, 2018

I'm curious, what would this be used for?

react and react-dom have UMD versions because it enables them to be run in a browser without any transform/bundling step. But the test renderer isn't really useful without a test runner, which should be capable of consuming the CJS build.

@srb101
Copy link
Author

srb101 commented Apr 10, 2018

Thanks for the response!

I'm working in an environment where npm isn't allowed (among other things) -- so we use Jasmine Standalone (SpecRunner) on the browser for JS Unit Testing.

I was planning to create some wrappers around react-dom-test-utils, react-test-renderer and react-test-renderer-shallow to make the testing slightly less painful.

@bvaughn
Copy link
Contributor

bvaughn commented Apr 10, 2018

Gotcha.

If you're not using NPM to install, would you be willing to just create your own UMD test renderer bundle? It would be pretty simple:

  1. Git clone this repo
  2. Apply the following patch:
diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js
index 138017b5d..bcf99ae52 100644
--- a/scripts/rollup/bundles.js
+++ b/scripts/rollup/bundles.js
@@ -156,7 +156,7 @@ const bundles = [
   /******* React Test Renderer *******/
   {
     label: 'test',
-    bundleTypes: [FB_DEV, NODE_DEV, NODE_PROD],
+    bundleTypes: [UMD_DEV, UMD_PROD],
     moduleType: RENDERER,
     entry: 'react-test-renderer',
     global: 'ReactTestRenderer',
  1. Run yarn build -- test-renderer to build the renderer.
./build/dist/react-test-renderer.development.js
./build/dist/react-test-renderer.production.min.js

Should give you a bundle that exports a global ReactTestRenderer variable.

@gaearon
Copy link
Collaborator

gaearon commented Apr 10, 2018

I guess it doesn't hurt us to add a UMD for it.

@bvaughn
Copy link
Contributor

bvaughn commented Apr 10, 2018

Sure. I'll toss up a PR for consideration.

@bvaughn
Copy link
Contributor

bvaughn commented Apr 10, 2018

Ok @srb101, the next release of the test renderer will have a UMD build. In the meanwhile, here you go:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants