Skip to content

Instantly share code, notes, and snippets.

@claudiainbytes
Created February 11, 2026 17:14
Show Gist options
  • Select an option

  • Save claudiainbytes/9aba29a29205732decd597440888acfd to your computer and use it in GitHub Desktop.

Select an option

Save claudiainbytes/9aba29a29205732decd597440888acfd to your computer and use it in GitHub Desktop.
1. Testing de Flujos de Usuario Completos
// Componente completo con múltiples interacciones
describe('Shopping Cart Flow', () => {
it('permite agregar, incrementar y eliminar productos', async () => {
const user = userEvent.setup()
render(<ShoppingApp />)
// Usuario agrega producto
const addButton = screen.getByRole('button', { name: /add to cart/i })
await user.click(addButton)
// Verifica que aparece en el carrito
expect(screen.getByText(/1 item in cart/i)).toBeInTheDocument()
// Incrementa cantidad
const incrementBtn = screen.getByRole('button', { name: /\+/i })
await user.click(incrementBtn)
expect(screen.getByText('Quantity: 2')).toBeInTheDocument()
// Elimina producto
const removeBtn = screen.getByRole('button', { name: /remove/i })
await user.click(removeBtn)
expect(screen.getByText(/cart is empty/i)).toBeInTheDocument()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment