Skip to content

Commit f6a6eda

Browse files
committed
refactor: adopt suggestions
1 parent f74db30 commit f6a6eda

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/helpers.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@ function _runWithRealTimers(callback) {
1818
setTimeout,
1919
}
2020

21-
try {
21+
// istanbul ignore else
22+
if (typeof jest !== 'undefined') {
2223
jest.useRealTimers()
23-
} catch (e) {
24-
// not running in jest environment
2524
}
2625

2726
const callbackReturnValue = callback()
2827

29-
const usedJestFakeTimers = Object.keys(timerAPI).filter(
30-
k => timerAPI[k] !== globalObj[k],
31-
).length
28+
const usedJestFakeTimers = Object.entries(timerAPI).some(
29+
([name, func]) => func !== globalObj[name],
30+
)
3231

3332
if (usedJestFakeTimers) {
3433
jest.useFakeTimers(timerAPI.setTimeout?.clock ? 'modern' : 'legacy')

0 commit comments

Comments
 (0)