Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Use caution with jest.useFakeTimers() #339

Open
leighman opened this issue Feb 24, 2023 · 1 comment
Open

[BUG] Use caution with jest.useFakeTimers() #339

leighman opened this issue Feb 24, 2023 · 1 comment
Labels

Comments

@leighman
Copy link

Just spent ages debugging why our tests were breaking when using DataLoader and eventually discovered that since we were using jest.useFakeTimers() it was never resolving the batch.
Would be good to have some kind of warning about this in the readme.

@leighman leighman added the bug label Feb 24, 2023
@pedrorfernandes
Copy link

pedrorfernandes commented Jul 5, 2023

it works with

jest.useFakeTimers({ advanceTimers: true });
// OR 
jest.useFakeTimers({ doNotFake: ["nextTick"] }); // if you really don't want process.nextTick to be monkey patched

because dataloader uses process.nextTick (if in node)

however, I still haven't figured out how to advance the timers properly to test the dataloader itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants