|
1 | 1 | ---
|
2 | 2 | id: testing
|
3 |
| -title: Testing Overview |
| 3 | +title: Visión general de Pruebas |
4 | 4 | permalink: docs/testing.html
|
5 | 5 | redirect_from:
|
6 | 6 | - "community/testing.html"
|
7 | 7 | next: testing-recipes.html
|
8 | 8 | ---
|
9 | 9 |
|
10 |
| -You can test React components similar to testing other JavaScript code. |
| 10 | +Puedes probar un componente de React similar a como pruebas otro código JavaScript. |
11 | 11 |
|
12 |
| -There are a few ways to test React components. Broadly, they divide into two categories: |
| 12 | +Hay varias formas de probar un componente React, la mayoría se agrupan en dos categorías: |
13 | 13 |
|
14 |
| -* **Rendering component trees** in a simplified test environment and asserting on their output. |
15 |
| -* **Running a complete app** in a realistic browser environment (also known as “end-to-end” tests). |
| 14 | +* **Renderizado del árbol de componentes** en un entorno de prueba simplificado y comprobando sus salidas. |
| 15 | +* **Ejecutando la aplicación completa** en un entorno de prueba más realista utilizando un navegador web (más conocido como pruebas “end-to-end”). |
16 | 16 |
|
17 |
| -This documentation section focuses on testing strategies for the first case. While full end-to-end tests can be very useful to prevent regressions to important workflows, such tests are not concerned with React components in particular, and are out of scope of this section. |
| 17 | +Esta sección de la documentación está enfocada en estrategias de prueba para el primer caso. Mientras las pruebas de tipo “end-to-end” pueden ser muy útiles para prever regresiones a flujos de trabajos importantes, estas pruebas no están relacionadas con los componentes React particularmente y están fuera del alcance de esta sección. |
18 | 18 |
|
19 |
| -### Tradeoffs {#tradeoffs} |
| 19 | +### Concesiones {#tradeoffs} |
20 | 20 |
|
21 | 21 |
|
22 |
| -When choosing testing tools, it is worth considering a few tradeoffs: |
| 22 | +Cuando estás eligiendo las herramientas para realizar las pruebas, vale la pena considerar algunas Concesiones: |
23 | 23 |
|
24 |
| -* **Iteration speed vs Realistic environment:** Some tools offer a very quick feedback loop between making a change and seeing the result, but don't model the browser behavior precisely. Other tools might use a real browser environment, but reduce the iteration speed and are flakier on a continuous integration server. |
25 |
| -* **How much to mock:** With components, the distinction between a "unit" and "integration" test can be blurry. If you're testing a form, should its test also test the buttons inside of it? Or should a button component have its own test suite? Should refactoring a button ever break the form test? |
| 24 | +* **Velocidad de iteración vs Entorno realista:** Algunas herramientas ofrecen un ciclo de retroalimentación muy rápido entre hacer un cambio y ver el resultado, pero no modelan el comportamiento del navegador con precisión. Otras herramientas pueden usar un entorno de navegador real, pero reducen la velocidad de iteración y son menos confiables en un servidor de integración continua. |
| 25 | +* **Cuanto abarcar:** Cuando pruebas componentes la diferencia entre Prueba Unitaria y Prueba de Integración puede ser borrosa. Si estas probando un formulario, se deben probar los botones del formulario en esta prueba? O el componente del botón debe tener su propia suit de pruebas? Debería la refactorización del botón afectar el resultado de las pruebas del formulario? |
26 | 26 |
|
27 |
| -Different answers may work for different teams and products. |
| 27 | +Diferentes respuestas pueden funcionar para diferentes equipos y diferentes productos. |
28 | 28 |
|
29 |
| -### Recommended Tools {#tools} |
| 29 | +### Herramientas recomendadas {#tools} |
30 | 30 |
|
31 |
| -**[Jest](https://facebook.github.io/jest/)** is a JavaScript test runner that lets you access the DOM via [`jsdom`](#mocking-a-rendering-surface). While jsdom is only an approximation of how the browser works, it is often good enough for testing React components. Jest provides a great iteration speed combined with powerful features like mocking [modules](#mocking-modules) and [timers](#mocking-timers) so you can have more control over how the code executes. |
| 31 | +**[Jest](https://facebook.github.io/jest/)** Es una biblioteca de JavaScript para ejecución de pruebas que permite acceder al DOM mediante [`jsdom`](/docs/testing-environments.html#mocking-a-rendering-surface). Aunque JSDOM solo se aproxima a como realmente los navegadores web trabajan, usualmente es suficiente para probar los componentes React. Jest brinda una gran velocidad de iteración combinada con potentes funcionalidades como simular [módulos](/docs/testing-environments.html#mocking-modules) y [temporizadores](/docs/testing-environments.html#mocking-timers) esto permite tener mayor control sobre como se ejecuta el código. |
32 | 32 |
|
33 |
| -**[React Testing Library](https://testing-library.com/react)** is a set of helpers that let you test React components without relying on their implementation details. This approach makes refactoring a breeze and also nudges you towards best practices for accessibility. Although it doesn't provide a way to "shallowly" render a component without its children, a test runner like Jest lets you do this by [mocking](/docs/testing-recipes.html#mocking-modules). |
| 33 | +**[Biblioteca de Pruebas para React](https://testing-library.com/react)** es una biblioteca de utilidades que te ayudan a probar componentes React sin depender de los detalles de su implementación. Este enfoque simplifica la refactorización y también lo empuja hacia las mejores prácticas de accesibilidad, aunque no proporciona una forma de renderizar "superficialmente" un componente sin sus hijos, Jest te permite hacerlo gracias a su funcionalidad para [simular](/docs/testing-recipes.html#mocking-modules). |
34 | 34 |
|
35 |
| -### Learn More {#learn-more} |
| 35 | +### Más Información {#learn-more} |
36 | 36 |
|
37 |
| -This section is divided in two pages: |
| 37 | +Esta sección esta dividida en dos paginas: |
38 | 38 |
|
39 |
| -- [Recipes](/docs/testing-recipes.html): Common patterns when writing tests for React components. |
40 |
| -- [Environments](/docs/testing-environments.html): What to consider when setting up a testing environment for React components. |
| 39 | +- [Recetas](/docs/testing-recipes.html): Patrones comunes cuando escribes pruebas para componentes React. |
| 40 | +- [Entornos](/docs/testing-environments.html): Que debes considerar cuando estes configurando un entorno de pruebas para componentes React. |
0 commit comments