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

169
Views
How to cover onIdle callback function with test react-idle-timer

I use react-idle-timer 4.6.4

I have a component with useIdleTimer hook.

import {useDispatch} from "react-redux";
import {logoutRequest} from "auth/actions";

const App = () => {
 const dispatch = useDispatch();
 const logout = () => dispatch(logoutRequest);

 useIdleTimer({
  timeout: 1000 * 60 * 5,
  onIdle: logout,
  debounce: 500
 });

 return <Component />
}

Also, I have a test that looks like this

test("render App", () => {
 render(<App />);
 const someElement = screen.getByText("Some element");
 expect(someElement).toBeInTheDocument();
})

This test covers all lines of code except for the logout function.

How to cover the logout function with tests?

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!