From 742c536753b91775a455e1d3a0084a49ba972653 Mon Sep 17 00:00:00 2001 From: Alex Krolick Date: Tue, 18 Sep 2018 10:55:46 -0700 Subject: [PATCH 1/2] Docs: show CJS workaround for #169 --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index e8c498fe..6677ff0b 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,33 @@ module.exports = { } ``` + +#### Export Issue with Babel Versions Lower Than 7 + +Babel versions lower than 7 throw an error when trying to override the named export in the example above. (See [bug](https://github.com/kentcdodds/react-testing-library/issues/169).) + +
+ Workaround + + +You can use CommonJS modules instead of ES modules, which should work in Node: + +```js +// test-utils.js +const rtl = require('react-testing-library') + +const customRender = (node, ...options) => { + return rtl.render({node}) +} + +module.exports = { + ...rtl, + render: customRender, +} +``` + +
+ ## Usage ### `render` From f2a3695dbc503d36e8a8a4fff6191a155b0da9c2 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Tue, 18 Sep 2018 12:55:21 -0600 Subject: [PATCH 2/2] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6677ff0b..17761ff1 100644 --- a/README.md +++ b/README.md @@ -275,11 +275,12 @@ module.exports = { #### Export Issue with Babel Versions Lower Than 7 -Babel versions lower than 7 throw an error when trying to override the named export in the example above. (See [bug](https://github.com/kentcdodds/react-testing-library/issues/169).) +Babel versions lower than 7 throw an error when trying to override the named export +in the example above. (See +[#169](https://github.com/kentcdodds/react-testing-library/issues/169).)
- Workaround - +Workaround You can use CommonJS modules instead of ES modules, which should work in Node: