Skip to content

Commit 5c4659e

Browse files
author
Kent C. Dodds
committed
docs: add faq for enzyme
1 parent 8a69556 commit 5c4659e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,29 @@ const allLisInDiv = container.querySelectorAll('div li')
241241
const rootElement = container.firstChild
242242
```
243243

244+
**What about enzyme is "bloated with complexity and features" and "encourage poor testing
245+
practices"**
246+
247+
Most of the damaging features have to do with encouraging testing implementation
248+
details. Primarily, these are
249+
[shallow rendering](http://airbnb.io/enzyme/docs/api/shallow.html), APIs which
250+
allow selecting rendered elements by component constructors, and APIs which
251+
allow you to get and interact with component instances (and their
252+
state/properties) (most of enzyme's wrapper APIs allow this).
253+
254+
The guiding principle for this library is:
255+
256+
> The less your tests resemble the way your software is used, the less confidence they can give you. - [17 Feb 2018](https://twitter.com/kentcdodds/status/965052178267176960)
257+
258+
Because users can't directly interact with your app's component instances,
259+
assert on their internal state or what components they render, or call their
260+
internal methods, doing those things in your tests reduce the confidence they're
261+
able to give you.
262+
263+
That's not to say that there's never a use case for doing those things, so they
264+
should be possible to accomplish, just not the default and natural way to test
265+
react components.
266+
244267
## Other Solutions
245268

246269
In preparing this project,

0 commit comments

Comments
 (0)