From 9600eda7a5427d5a914e3b08353541a1f1b46c06 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Thu, 12 Oct 2017 18:12:44 +0800 Subject: [PATCH] enzyme: clarify installation section --- enzyme.md | 71 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/enzyme.md b/enzyme.md index e983c3ad2..c0f123c0e 100644 --- a/enzyme.md +++ b/enzyme.md @@ -9,7 +9,40 @@ intro: | --- ## Getting started -{: .-three-column} + +### Mounting +{: .-prime} + +```js +import {shallow, mount} from 'enzyme' +``` +{: .-setup} + +```js +wrap = shallow() +``` + +```js +wrap = mount() +``` + +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) + +### Debugging + +```js +console.log(wrap.debug()) +``` + +Shows HTML for debugging purposes. + +See: [debug()](http://airbnb.io/enzyme/docs/api/ReactWrapper/debug.html) + +## Installing ### Initial setup @@ -39,29 +72,9 @@ Enzyme.configure({ adapter: new Adapter() }) } ``` -This configures Enzyme for React v16, and Jest to automatically configure Enzyme for you. There are other adapters in Enzyme's [installation instructions](http://airbnb.io/enzyme/#installation). +This configures Enzyme for React v16, and Jest to automatically configure Enzyme for you. There are other adapters in Enzyme's installation instructions. -### Mounting -{: .-prime} - -```js -import {shallow, mount} from 'enzyme' -``` -{: .-setup} - -```js -wrap = shallow() -``` - -```js -wrap = mount() -``` - -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: [Installation](http://airbnb.io/enzyme/#installation) ### Jest snapshots @@ -89,20 +102,10 @@ it('works', () => { }) ``` -Converts an Enzyme wrapper to a format compatible with Jest snapshots. +Optional, but recommended: This allows you to use Enzyme wrappers with Jest snapshots. See: [enzyme-to-json](https://www.npmjs.com/package/enzyme-to-json) -### Debugging - -```js -console.log(wrap.debug()) -``` - -Shows HTML for debugging purposes. - -See: [debug()](http://airbnb.io/enzyme/docs/api/ReactWrapper/debug.html) - ## ReactWrapper ### Traversing