No tienes acceso a esta clase

¡Continúa aprendiendo! Únete y comienza a potenciar tu carrera

Curso de React Testing Library

Curso de React Testing Library

Wilmer Javier Garzon Cabezas

Wilmer Javier Garzon Cabezas

Testeo de Custom Hooks con Testing Library React Hooks

13/20
Recursos

Comando para instalar la dependencia de desarrollo para hacer test de custom Hooks

yarn add -D @testing-library/react-hooks

 

Aportes 2

Preguntas 0

Ordenar por:

¿Quieres ver más aportes, preguntas y respuestas de la comunidad?

A partir de **React Testing Library v13** ya no es necesario instalar la liberia `@testing-library/react-hooks`. Ahora es tan simple como: `import { renderHook, waitFor } from "@testing-library/react";` Como podran notar tambien importe el `waitFor` pues el mismo comportamiento de `waitForNextUpdate` (no disponible) se puede simular con esta funcionalidad. El ejercicio de la clase quedaria de la siguiente manera: ![](https://static.platzi.com/media/user_upload/image-1435ffa9-c6e0-410f-b23c-657a712949f9.jpg)
![](https://static.platzi.com/media/user_upload/image-9ff642ea-bd06-4348-91cf-3b2e39e646e4.jpg) Otra alternativa por si les resulta un error con el waitForNextUpdate(): TypeError: waitForNextUpdate is not a function ❯ src/hooks/useOrders.test.ts:57:15 55| 56| // Wait for the hook to update after fetching orders 57| await waitForNextUpdate(); | ^ 58| 59| // Ensure the loading state is false and orders are loaded