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

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