You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const setTimeoutCopy = setTimeout
let waitingTime = 0
jest.spyOn(global, "setTimeout").mockImplementation((f, ms) => {
waitingTime += ms
return setTimeoutCopy(f, 0)
})
However, this seems to have no effect on p-queue.
And my test times out with:
Error: thrown: "Exceeded timeout of 5000 ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
Would appreciate some guidance.
The text was updated successfully, but these errors were encountered:
I've removed await from my method and added await jest.runAllTimersAsync(); await flushPromises();
constflushPromises=()=>{// Wait for promises running in the non-async timer callback to complete.// From https://stackoverflow.com/a/58716087/308237returnnewPromise((resolve)=>{returnsetImmediate(resolve);});};test('my test',async()=>{myAsyncMethod();awaitjest.runAllTimersAsync();awaitflushPromises();expect(true).toBe(true);});
I am trying to test my code that makes use of p-queue.
However, I don't want my test to actually wait for seconds. I tried to use https://jestjs.io/docs/timer-mocks.
jest.useFakeTimers();
I also tried to mock setTimeout myself
However, this seems to have no effect on p-queue.
And my test times out with:
Would appreciate some guidance.
The text was updated successfully, but these errors were encountered: