This website collects cookies to deliver better user experience
The test uses a React Component to test the sut's behaviour. It shows how the hook should be used.
The Test uses useFakeTimers to control the pass of time and assert when the debounced value should and should not be changed
useFakeTimers
act(() => { jest.advanceTimersByTime(1); }); expect(debouncedValue.textContent).toBe('3'); // fails, got 0 instead of 3 expect(value.textContent).toBe('3');
29
0