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

How can we make Enzyme part of the default testing config for React? #119

Closed
insin opened this issue Jun 9, 2016 · 3 comments
Closed

How can we make Enzyme part of the default testing config for React? #119

insin opened this issue Jun 9, 2016 · 3 comments

Comments

@insin
Copy link
Owner

insin commented Jun 9, 2016

Related Twitter thread: https://twitter.com/jbscript/status/740949154264813569

@insin
Copy link
Owner Author

insin commented Jun 9, 2016

First thoughts:
I've tried to avoid nwb needing to have React in dependencies (which is why redbox-noreact exists)


Second thoughts:
Why?


First thoughts:
Shut up.
Enzyme has a peerDependency on React, which makes it problematic to include in a global install of nwb (and for a local install when using nwb for non-React projects, which will generate peerDependency installation or warnings depending on your version of npm).


Second thoughts:
Why is it problematic for a global install?
So what if non-React projects pull in another few React dependencies?
There are already a bunch of React-specific dependencies - shouldn't these be split out into a separate nwb-react module which gets included in React project skeletons?

    "babel-plugin-react-display-name": "2.0.0",
    "babel-plugin-react-transform": "1.1.1",
    "react-transform-catch-errors": "1.0.2",
    "react-transform-hmr": "1.0.4",
    "redbox-noreact": "1.1.0",

First thoughts:
Having different versions of React installed locally and globally opens up the possibility of having two different versions of React in play - a global Enzyme dependency will resolve nwb's version of React first.


Third thoughts:
Is this really an effective way to find out why you've done things the way you've done them and if you've really done the work to validate your own assumptions?
Get some sleep

To be continued....

@caseybaggz
Copy link

Can this be closed since we now have the config settings? Seems to work fine for me?

nwb.config:

compat: {
    enzyme: true
 }

@insin
Copy link
Owner Author

insin commented Dec 12, 2017

Enzyme now requires you to configure an adapter rather than needing Webpack workarounds when importing it in your tests: https://github.com/airbnb/enzyme/blob/master/docs/installation/react-16.md

@insin insin closed this as completed Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants