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 f74db30 commit f6a6edaCopy full SHA for f6a6eda
src/helpers.js
@@ -18,17 +18,16 @@ function _runWithRealTimers(callback) {
18
setTimeout,
19
}
20
21
- try {
+ // istanbul ignore else
22
+ if (typeof jest !== 'undefined') {
23
jest.useRealTimers()
- } catch (e) {
24
- // not running in jest environment
25
26
27
const callbackReturnValue = callback()
28
29
- const usedJestFakeTimers = Object.keys(timerAPI).filter(
30
- k => timerAPI[k] !== globalObj[k],
31
- ).length
+ const usedJestFakeTimers = Object.entries(timerAPI).some(
+ ([name, func]) => func !== globalObj[name],
+ )
32
33
if (usedJestFakeTimers) {
34
jest.useFakeTimers(timerAPI.setTimeout?.clock ? 'modern' : 'legacy')
0 commit comments