You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var ShallowRenderer =require('react-test-renderer/shallow'); // ES5 with npm
14
14
```
15
15
16
-
## Overview {#overview}
16
+
## 概览 {#overview}
17
17
18
-
When writing unit tests for React, shallow rendering can be helpful. Shallow rendering lets you render a component "one level deep" and assert facts about what its render method returns, without worrying about the behavior of child components, which are not instantiated or rendered. This does not require a DOM.
Shallow testing currently has some limitations, namely not supporting refs.
50
+
浅层测试(Shallow testing)目前有些局限性,即不支持 refs。
51
51
52
-
> Note:
52
+
> 注意:
53
53
>
54
-
> We also recommend checking out Enzyme's [Shallow Rendering API](https://airbnb.io/enzyme/docs/api/shallow.html). It provides a nicer higher-level API over the same functionality.
`shallowRenderer.render()`is similar to [`ReactDOM.render()`](/docs/react-dom.html#render)but it doesn't require DOM and only renders a single level deep. This means you can test components isolated from how their children are implemented.
62
+
`shallowRenderer.render()`和 [`ReactDOM.render()`](/docs/react-dom.html#render)很像,但是它不依赖 DOM 且只渲染一层。这意味着你可以对组件和其子组件的实现进行隔离测试。
0 commit comments