title: Enzyme
category: React
layout: 2017/sheet
-updated: 2018-04-27
+updated: 2020-02-12
tags: [Featured]
weight: -1
keywords:
- wrap.setProps()
- "wrap.find().simulate('click')"
- "wrap.contains(<div/>)"
-intro: |
- [Enzyme](http://airbnb.io/enzyme) lets you write unit tests for React components. This guide covers Enzyme 3.x.
---
## Getting started
+### Introduction
+{: .-intro}
+
+[Enzyme](https://airbnb.io/enzyme) lets you write unit tests for React components. This guide covers Enzyme 3.x.
+
+- [Enzyme website](https://enzymejs.github.io/enzyme/) _(enzymejs.github.io)_
+
### Mounting
{: .-prime}
Shallow wrapping doesn't descend down to sub-components.
A full mount also mounts sub-components.
-See: [Shallow rendering](http://airbnb.io/enzyme/docs/api/shallow.html),
-[Full rendering](http://airbnb.io/enzyme/docs/api/mount.html)
+See: [Shallow rendering](https://airbnb.io/enzyme/docs/api/shallow.html),
+[Full rendering](https://airbnb.io/enzyme/docs/api/mount.html)
### Debugging
Shows HTML for debugging purposes.
-See: [debug()](http://airbnb.io/enzyme/docs/api/ReactWrapper/debug.html)
+See: [debug()](https://airbnb.io/enzyme/docs/api/ReactWrapper/debug.html)
## Examples
{: .-three-column}
#### Asserting
```js
-expect(wrap.props('name')).toEqual('Moe')
+expect(wrap.prop('name')).toEqual('Moe')
expect(wrap.state('show')).toEqual(true)
```
```js
-expect('name' in wrap.props()).toEqual(true)
+expect('name' in wrap.props()).toEqual('Moe')
expect('show' in wrap.state()).toEqual(true)
```
This configures Enzyme for React v16, and Jest to automatically configure Enzyme for you. There are other adapters in Enzyme's installation instructions.
-See: [Installation](http://airbnb.io/enzyme/#installation)
+See: [Installation](https://airbnb.io/enzyme/#installation)
### Jest snapshots
```js
wrap.get(0) // → ReactElement
-wrap.getNode() // → ReactElement
-wrap.getNodes() // → Array<ReactElement>
+wrap.getElement() // → ReactElement
+wrap.getElements() // → Array<ReactElement>
wrap.getDOMNode() // → DOMComponent
```
-See: [Full rendering API](http://airbnb.io/enzyme/docs/api/mount.html)
+See: [Full rendering API](https://airbnb.io/enzyme/docs/api/mount.html)
### Actions
```js
wrap.state('key') // → any
-wrap.prop('key') // → any
+wrap.prop('key') // → any
wrap.context('key') // → any
```