Skip to content

Commit

Permalink
Translate shallow-renderer (#56)
Browse files Browse the repository at this point in the history
* translate shallow-renderer

* レンダリング => レンダー

* Update content/docs/addons-shallow-renderer.md

Co-Authored-By: sakito21 <[email protected]>

* Update content/docs/addons-shallow-renderer.md

Co-Authored-By: sakito21 <[email protected]>

* Update content/docs/addons-shallow-renderer.md

Co-Authored-By: sakito21 <[email protected]>

* 英字、数字の前後に空白を入れる修正

* 不要に訳し過ぎていたと思う部分を修正

* Update content/docs/addons-shallow-renderer.md

Co-Authored-By: sakito21 <[email protected]>

* Update content/docs/addons-shallow-renderer.md

Co-Authored-By: sakito21 <[email protected]>

* Update content/docs/addons-shallow-renderer.md

Co-Authored-By: sakito21 <[email protected]>

* Update content/docs/addons-shallow-renderer.md

Co-Authored-By: sakito21 <[email protected]>
  • Loading branch information
sakit0 authored and koba04 committed Feb 7, 2019
1 parent 17d99b3 commit 81db23d
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions content/docs/addons-shallow-renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ id: shallow-renderer
title: Shallow Renderer
permalink: docs/shallow-renderer.html
layout: docs
category: Reference
category: リファレンス
---

**Importing**
**インポート**

```javascript
import ShallowRenderer from 'react-test-renderer/shallow'; // ES6
var ShallowRenderer = require('react-test-renderer/shallow'); // ES5 with npm
```

## Overview
## 概要

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.
React の単体テストを実装するとき、Shallow Renderer が役立つでしょう。浅いレンダー (shallow rendering) を使用すると、インスタンス化またはレンダーされていない子コンポーネントの振る舞いを心配することなく、「1 階層深く」レンダーしてレンダーメソッドが返すものを assert できます。これに DOM は必要ありません。

For example, if you have the following component:
たとえば、以下のコンポーネントがある場合:

```javascript
function MyComponent() {
Expand All @@ -30,7 +30,7 @@ function MyComponent() {
}
```

Then you can assert:
以下のように assert できます:

```javascript
import ShallowRenderer from 'react-test-renderer/shallow';
Expand All @@ -47,22 +47,22 @@ expect(result.props.children).toEqual([
]);
```

Shallow testing currently has some limitations, namely not supporting refs.
浅いレンダーによるテストには現在いくつかの制限があります。すなわち ref をサポートしていません。

> Note:
> 補足:
>
> We also recommend checking out Enzyme's [Shallow Rendering API](http://airbnb.io/enzyme/docs/api/shallow.html). It provides a nicer higher-level API over the same functionality.
> また Enzyme[Shallow Rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) をチェックすることをお勧めします。それは同じ機能上でより良くより高いレベルの API を提供します。
## Reference
## リファレンス

### `shallowRenderer.render()`

You can think of the shallowRenderer as a "place" to render the component you're testing, and from which you can extract the component's output.
shallowRenderer は、テストしているコンポーネントをレンダーするための「場所」と捉えることができ、そこからコンポーネントの出力を抽出できます。

`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.
`shallowRenderer.render()` [`ReactDOM.render()`](/docs/react-dom.html#render) に似ていますが、 DOM を必要とせず、1 階層だけレンダーします。つまり、テスト対象のコンポーネントが持つ子コンポーネントの実装から分離してテストを実行できます。

### `shallowRenderer.getRenderOutput()`

After `shallowRenderer.render()` has been called, you can use `shallowRenderer.getRenderOutput()` to get the shallowly rendered output.
`shallowRenderer.render()` が呼び出された後、`shallowRenderer.getRenderOutput()` を使用して浅くレンダーされた出力を取得できます。

You can then begin to assert facts about the output.
そして出力から得た結果の assert を開始できます。

0 comments on commit 81db23d

Please sign in to comment.