Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

346
Vistas
unit Testing: How to Simulate back button click in the brower

I have case of testing which i need Simulate click back button in the browser

what i tryed to do like this :

test('Then i click on back button on the brwoser should stay on Bills Page',()=>{
  const data = []
  const loading = false
  const error = null
  const pathname = ROUTES_PATH['Bills']
  const html = ROUTES({ 
    pathname,
    data,
    loading,
    error
   })
   document.body.innerHTML = html
   const back=jest.fn(window.history.back())
   userEvent.click(back)
   expect(back).toHaveBeenCalled()
   expect(screen.getAllByText('Mes notes de frais')).toBeTruthy()
})

i don't know if what i write is correct , any why i have error in my jest enter image description here

correct me if what i tred to do is incorrect i use @testing-library/user-event library

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda