We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 54fd7f3 commit 84edc56Copy full SHA for 84edc56
readme.md
@@ -739,6 +739,23 @@ for await (const result of pMapIterable(
739
}
740
```
741
742
+#### How do I test code that uses `p-queue` with Jest fake timers?
743
+
744
+Jest fake timers don't work well with `p-queue` because it uses `queueMicrotask` internally.
745
746
+Workaround:
747
748
+```js
749
+const flushPromises = () => new Promise(resolve => setImmediate(resolve));
750
751
+jest.useFakeTimers();
752
753
+// ... your test code ...
754
755
+await jest.runAllTimersAsync();
756
+await flushPromises();
757
+```
758
759
## Maintainers
760
761
- [Sindre Sorhus](https://github.com/sindresorhus)
0 commit comments