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

Table Driven Testing en React

5/20
Recursos

Aportes 1

Preguntas 1

Ordenar por:

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

Test de la clase incluyendo la división entre cero: ```js import { describe, it, expect } from 'vitest'; import { render, screen } from '@testing-library/react'; import { Calculator } from './Calculator'; describe('<Calculator />', () => { const useCasesTest = [ { a : 2, b : 3, operation : 'add', expected : 5 }, { a : 5, b : 3, operation : 'subtract', expected : 2 }, { a : 2, b : 3, operation : 'multiply', expected : 6 }, { a : 6, b : 3, operation : 'divide', expected : 2 }, { a : 6, b : 0, operation : 'divide', expected : "Error" }, ]; it.each(useCasesTest)('renders calculator with %p expected $expected when $a and $b will be $operation', ({ a, b, operation, expected }) => { render(<Calculator a={a} b={b} operation={operation} />); const result = screen.getByText(`Result: ${expected}`); expect(result).toBeInTheDocument(); }); }); ```import { describe, it, expect } from 'vitest';import { render, screen } from '@testing-library/react';import { Calculator } from './Calculator'; describe('\<Calculator />', () => { const useCasesTest = \[ { a : 2, b : 3, operation : 'add', expected : 5 }, { a : 5, b : 3, operation : 'subtract', expected : 2 }, { a : 2, b : 3, operation : 'multiply', expected : 6 }, { a : 6, b : 3, operation : 'divide', expected : 2 }, { a : 6, b : 0, operation : 'divide', expected : "Error" }, ]; it.each(useCasesTest)('renders calculator with %p expected $expected when $a and $b will be $operation', ({ a, b, operation, expected }) => { render(*\<Calculator* a={a} b={b} operation={operation} */>*); const result = screen.getByText(`Result: ${expected}`); expect(result).toBeInTheDocument(); });});