Pruebas unitarias en E-commerce Web

React Testing Library

Ejemplos

// Bad
expect(
  screen
  .getByRole("img", {
    name: /Pague 11 lleve 12 en jabón supremo 300g/i
  })
  .closest("a") // Avoid direct node access
).toHaveAttribute("href", "/promo-detail/C-6912");


// Good
expect(
  screen
  .getByRole("link", {
    name: /Pague 11 lleve 12 en jabón supremo 300g/i
  })
).toHaveAttribute("href", "/promo-detail/C-6912");

Probando el componente

Evite el acceso directo al node. Prefiero usar los métodos de Testing Library

Resultado

 

Continuous Integration - Jenkins

Pipeline Jenkins

That's all folks!

E-commerce Tests

By Bruno Macedo