Skip to content

Commit 789ee56

Browse files
Merge pull request #73 from d4vsanchez/master
Translate: Test Utilities
2 parents 3e28edb + a7ed524 commit 789ee56

File tree

1 file changed

+38
-39
lines changed

1 file changed

+38
-39
lines changed

content/docs/addons-test-utils.md

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
---
22
id: test-utils
3-
title: Test Utilities
3+
title: Utilidades para pruebas
44
permalink: docs/test-utils.html
55
layout: docs
66
category: Reference
77
---
88

9-
**Importing**
9+
**Importando**
1010

1111
```javascript
1212
import ReactTestUtils from 'react-dom/test-utils'; // ES6
1313
var ReactTestUtils = require('react-dom/test-utils'); // ES5 with npm
1414
```
1515

16-
## Overview
16+
## Introducción
1717

18-
`ReactTestUtils` makes it easy to test React components in the testing framework of your choice. At Facebook we use [Jest](https://facebook.github.io/jest/) for painless JavaScript testing. Learn how to get started with Jest through the Jest website's [React Tutorial](http://facebook.github.io/jest/docs/en/tutorial-react.html#content).
18+
`ReactTestUtils` facilita probar los componentes de React en cualquiera de los frameworks de pruebas que elijas. En Facebook usamos [Jest](https://facebook.github.io/jest/) para realizar las pruebas de JavaScript sin problemas. Aprende como iniciar con Jest en el [tutorial para React](http://facebook.github.io/jest/docs/en/tutorial-react.html#content) que se encuentra en el sitio web de Jest.
1919

20-
> Note:
20+
> Nota:
2121
>
22-
> Airbnb has released a testing utility called Enzyme, which makes it easy to assert, manipulate, and traverse your React Components' output. If you're deciding on a unit testing utility to use together with Jest, or any other test runner, it's worth checking out: [http://airbnb.io/enzyme/](http://airbnb.io/enzyme/)
22+
> Airbnb ha liberado una utilidad para pruebas llamada Enzyme, que hace fácil asegurar, manipular y navegar por el resultado de sus Componentes de React. Si está decidiendo que utilidad para pruebas unitarias utilizar junto con Jest u otra herramienta para pruebas, vale la pena darle un vistazo a: [http://airbnb.io/enzyme/](http://airbnb.io/enzyme/)
2323
>
24-
> Alternatively, there is another testing utility called react-testing-library designed to enable and encourage writing tests that use your components as the end users use them. It also works with any test runner: [https://git.io/react-testing-library](https://git.io/react-testing-library)
24+
> Como otra opción, también hay otra utilidad para pruebas llamada react-testing-library diseñada para permitir e incentivar el escribir las pruebas de sus componentes de la misma forma en que los usuarios finales los usarían. De igual forma, funciona con cualquiera de los ejecutores de pruebas: [https://git.io/react-testing-library](https://git.io/react-testing-library)
2525
2626
- [`Simulate`](#simulate)
2727
- [`renderIntoDocument()`](#renderintodocument)
@@ -39,18 +39,18 @@ var ReactTestUtils = require('react-dom/test-utils'); // ES5 with npm
3939
- [`scryRenderedComponentsWithType()`](#scryrenderedcomponentswithtype)
4040
- [`findRenderedComponentWithType()`](#findrenderedcomponentwithtype)
4141

42-
## Reference
42+
## Referencia
4343

44-
## Shallow Rendering
44+
## Renderizado superficial
4545

46-
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.
46+
Cuando se escriben pruebas de unidad para React, el renderizado superficial puede ser de ayuda. El renderizado superficial permite renderizar el componente "un nivel de profundidad" y asegurar lo que su método de renderizado retorna, sin preocuparse acerca del comportamiento de los componentes hijos, los cuales no son instanciados o renderizados. Esto no requiere de un DOM.
4747

48-
> Note:
48+
> Nota:
4949
>
50-
> The shallow renderer has moved to `react-test-renderer/shallow`.<br>
51-
> [Learn more about shallow rendering on its reference page.](/docs/shallow-renderer.html)
50+
> El renderizado superficial se ha movido a `react-test-renderer/shallow`.<br>
51+
> [Puede encontrar más información sobre el renderizado superficial en su página de referencia](/docs/shallow-renderer.html)
5252
53-
## Other Utilities
53+
## Otras utilidades
5454

5555
### `Simulate`
5656

@@ -61,19 +61,19 @@ Simulate.{eventName}(
6161
)
6262
```
6363

64-
Simulate an event dispatch on a DOM node with optional `eventData` event data.
64+
Simula la ejecución de un evento en un nodo del DOM con los datos opcionales de evento `eventData`.
6565

66-
`Simulate` has a method for [every event that React understands](/docs/events.html#supported-events).
66+
`Simulate` tiene un método para [cada uno de los eventos que React comprende](/docs/events.html#supported-events).
6767

68-
**Clicking an element**
68+
**Haciendo clic en un elemento**
6969

7070
```javascript
7171
// <button ref={(node) => this.button = node}>...</button>
7272
const node = this.button;
7373
ReactTestUtils.Simulate.click(node);
7474
```
7575

76-
**Changing the value of an input field and then pressing ENTER.**
76+
**Cambiar el valor en un campo de entrada y presionar ENTER.**
7777

7878
```javascript
7979
// <input ref={(node) => this.textInput = node} />
@@ -83,9 +83,9 @@ ReactTestUtils.Simulate.change(node);
8383
ReactTestUtils.Simulate.keyDown(node, {key: "Enter", keyCode: 13, which: 13});
8484
```
8585

86-
> Note
86+
> Nota
8787
>
88-
> You will have to provide any event property that you're using in your component (e.g. keyCode, which, etc...) as React is not creating any of these for you.
88+
> Se debe proveer cualquiera de las propiedades del evento que se esté usando en tu componente (p.e. keyCode, which, etc...) ya que React no creará ninguna de estas por ti.
8989
9090
* * *
9191

@@ -95,11 +95,11 @@ ReactTestUtils.Simulate.keyDown(node, {key: "Enter", keyCode: 13, which: 13});
9595
renderIntoDocument(element)
9696
```
9797

98-
Render a React element into a detached DOM node in the document. **This function requires a DOM.**
98+
Renderiza un Elemento de React en un nodo separado del DOM en el documento. **Esta función requiere un DOM**
9999

100-
> Note:
100+
> Nota:
101101
>
102-
> You will need to have `window`, `window.document` and `window.document.createElement` globally available **before** you import `React`. Otherwise React will think it can't access the DOM and methods like `setState` won't work.
102+
> Necesitará tener `window`, `window.document` y `window.document.createElement` habilitados de forma global **antes** de importar `React`. De otro modo React pensará que no tiene acceso al DOM y los métodos como `setState` no funcionarán.
103103
104104
* * *
105105

@@ -112,11 +112,11 @@ mockComponent(
112112
)
113113
```
114114

115-
Pass a mocked component module to this method to augment it with useful methods that allow it to be used as a dummy React component. Instead of rendering as usual, the component will become a simple `<div>` (or other tag if `mockTagName` is provided) containing any provided children.
115+
Pasa un módulo de un componente a simular a este método para mejorarlo con métodos útiles los cuales permiten que sea utilizado como un componente de React simulado. En lugar de renderizar de la forma usual, el componente simplemente se convertirá en un `<div>` (u otra etiqueta si se proporciona `mockTagName`) que contiene cualquiera de los hijos proporcionados.
116116

117-
> Note:
117+
> Nota:
118118
>
119-
> `mockComponent()` is a legacy API. We recommend using [shallow rendering](/docs/test-utils.html#shallow-rendering) or [`jest.mock()`](https://facebook.github.io/jest/docs/en/tutorial-react-native.html#mock-native-modules-using-jestmock) instead.
119+
> `mockComponent()` es una API heredada. En su lugar, recomendamos usar [renderizado superficial](/docs/test-utils.html#shallow-rendering) o [`jest.mock()`](https://facebook.github.io/jest/docs/en/tutorial-react-native.html#mock-native-modules-using-jestmock).
120120
121121
* * *
122122

@@ -126,7 +126,7 @@ Pass a mocked component module to this method to augment it with useful methods
126126
isElement(element)
127127
```
128128

129-
Returns `true` if `element` is any React element.
129+
Retorna `true` si `element` es cualquier elemento de React.
130130

131131
* * *
132132

@@ -139,7 +139,7 @@ isElementOfType(
139139
)
140140
```
141141

142-
Returns `true` if `element` is a React element whose type is of a React `componentClass`.
142+
Retorna `true` si `element` es un Elemento de React cuyo tipo es un `componentClass` de React.
143143

144144
* * *
145145

@@ -149,7 +149,7 @@ Returns `true` if `element` is a React element whose type is of a React `compone
149149
isDOMComponent(instance)
150150
```
151151

152-
Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
152+
Retorna `true` si `instance` es un componente del DOM (tal como un `<div>` o `<span>`).
153153

154154
* * *
155155

@@ -159,7 +159,7 @@ Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
159159
isCompositeComponent(instance)
160160
```
161161

162-
Returns `true` if `instance` is a user-defined component, such as a class or a function.
162+
Retorna `true` si `instance` es un componente definido por el usuario, tal como una clase o una función.
163163

164164
* * *
165165

@@ -172,7 +172,7 @@ isCompositeComponentWithType(
172172
)
173173
```
174174

175-
Returns `true` if `instance` is a component whose type is of a React `componentClass`.
175+
Retorna `true` si `instance` es un componente cuyo tipo es un `componentClass` de React.
176176

177177
* * *
178178

@@ -185,7 +185,7 @@ findAllInRenderedTree(
185185
)
186186
```
187187

188-
Traverse all components in `tree` and accumulate all components where `test(component)` is `true`. This is not that useful on its own, but it's used as a primitive for other test utils.
188+
Navega por todos los componentes en `tree` y acumula todos los componentes en donde `test(component)` sea `true`. Esto no es útil por sí solo, pero es utilizado como primitivo para otras utilidades de prueba.
189189

190190
* * *
191191

@@ -198,7 +198,7 @@ scryRenderedDOMComponentsWithClass(
198198
)
199199
```
200200

201-
Finds all DOM elements of components in the rendered tree that are DOM components with the class name matching `className`.
201+
Encuentra todos los elementos en el DOM de componentes presentes en el árbol de renderizado que sean componentes del DOM cuyo nombre de clase sea `className`.
202202

203203
* * *
204204

@@ -211,7 +211,7 @@ findRenderedDOMComponentWithClass(
211211
)
212212
```
213213

214-
Like [`scryRenderedDOMComponentsWithClass()`](#scryrendereddomcomponentswithclass) but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.
214+
Igual a [`scryRenderedDOMComponentsWithClass()`](#scryrendereddomcomponentswithclass) pero espera que sólo haya un resultado, y retorna ese único resultado, de lo contrario lanza una excepción si hay algún otro número de coincidencias diferentes a una.
215215

216216
* * *
217217

@@ -224,7 +224,7 @@ scryRenderedDOMComponentsWithTag(
224224
)
225225
```
226226

227-
Finds all DOM elements of components in the rendered tree that are DOM components with the tag name matching `tagName`.
227+
Encuentra todos los elementos en el DOM de componentes presentes en el árbol de renderizado que sean componentes del DOM cuyo nombre de etiqueta sea igual a `tagName`.
228228

229229
* * *
230230

@@ -237,7 +237,7 @@ findRenderedDOMComponentWithTag(
237237
)
238238
```
239239

240-
Like [`scryRenderedDOMComponentsWithTag()`](#scryrendereddomcomponentswithtag) but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.
240+
Igual a [`scryRenderedDOMComponentsWithTag()`](#scryrendereddomcomponentswithtag) pero espera que sólo haya un resultado y retorna ese único resultado, de lo contario lanza una excepción si hay algún otro número de coincidencias diferentes a una.
241241

242242
* * *
243243

@@ -250,7 +250,7 @@ scryRenderedComponentsWithType(
250250
)
251251
```
252252

253-
Finds all instances of components with type equal to `componentClass`.
253+
Encuentra todas las instancias de componentes cuyo tipo sea igual a `componentClass`.
254254

255255
* * *
256256

@@ -263,7 +263,6 @@ findRenderedComponentWithType(
263263
)
264264
```
265265

266-
Same as [`scryRenderedComponentsWithType()`](#scryrenderedcomponentswithtype) but expects there to be one result and returns that one result, or throws exception if there is any other number of matches besides one.
266+
Igual a [`scryRenderedComponentsWithType()`](#scryrenderedcomponentswithtype) pero espera que sólo haya un resultado y retorna ese único resultado, de lo contrario lanza una excepción si hay algún otro número de coincidencias diferentes a una.
267267

268268
* * *
269-

0 commit comments

Comments
 (0)