Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

344
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!