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
Copy file name to clipboardExpand all lines: content/docs/addons-test-utils.md
-71Lines changed: 0 additions & 71 deletions
Original file line number
Diff line number
Diff line change
@@ -19,15 +19,9 @@ var ReactTestUtils = require('react-dom/test-utils'); // ES5 with npm
19
19
20
20
> Nota:
21
21
>
22
-
<<<<<<< HEAD
23
-
> 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/)
24
-
>
25
-
> 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)
26
-
=======
27
22
> We recommend using [`react-testing-library`](https://git.io/react-testing-library) which is designed to enable and encourage writing tests that use your components as the end users do.
28
23
>
29
24
> Alternatively, Airbnb has released a testing utility called [Enzyme](http://airbnb.io/enzyme/), which makes it easy to assert, manipulate, and traverse your React Components' output.
30
-
>>>>>>> 98c1d22fbef2638cafb03b07e0eabe2a6186fca8
31
25
32
26
-[`act()`](#act)
33
27
-[`mockComponent()`](#mockcomponent)
@@ -48,67 +42,6 @@ var ReactTestUtils = require('react-dom/test-utils'); // ES5 with npm
48
42
49
43
## Referencia
50
44
51
-
<<<<<<< HEAD
52
-
## Renderizado superficial
53
-
54
-
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.
55
-
56
-
> Nota:
57
-
>
58
-
> El renderizado superficial se ha movido a `react-test-renderer/shallow`.<br>
59
-
> [Puede encontrar más información sobre el renderizado superficial en su página de referencia](/docs/shallow-renderer.html)
60
-
61
-
## Otras utilidades
62
-
63
-
### `Simulate`
64
-
65
-
```javascript
66
-
Simulate.{eventName}(
67
-
element,
68
-
[eventData]
69
-
)
70
-
```
71
-
72
-
Simula la ejecución de un evento en un nodo del DOM con los datos opcionales de evento `eventData`.
73
-
74
-
`Simulate` tiene un método para [cada uno de los eventos que React comprende](/docs/events.html#supported-events).
> 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.
97
-
98
-
* * *
99
-
100
-
### `renderIntoDocument()`
101
-
102
-
```javascript
103
-
renderIntoDocument(element)
104
-
```
105
-
106
-
Renderiza un Elemento de React en un nodo separado del DOM en el documento. **Esta función requiere un DOM**
107
-
108
-
> Nota:
109
-
>
110
-
> 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.
111
-
=======
112
45
### `act()`
113
46
114
47
To prepare a component for assertions, wrap the code rendering it and performing updates inside an `act()` call. This makes your test run closer to how React works in the browser.
@@ -190,7 +123,6 @@ it('can render and update a counter', () => {
190
123
```
191
124
192
125
Don't forget that dispatching DOM events only works when the DOM container is added to the `document`. You can use a helper like [`react-testing-library`](https://github.com/kentcdodds/react-testing-library) to reduce the boilerplate code.
> 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.
> 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.
0 commit comments