Skip to content

Commit

Permalink
refactor: adopt suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ph-fritsche committed Feb 11, 2021
1 parent f74db30 commit f6a6eda
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ function _runWithRealTimers(callback) {
setTimeout,
}

try {
// istanbul ignore else
if (typeof jest !== 'undefined') {
jest.useRealTimers()
} catch (e) {
// not running in jest environment
}

const callbackReturnValue = callback()

const usedJestFakeTimers = Object.keys(timerAPI).filter(
k => timerAPI[k] !== globalObj[k],
).length
const usedJestFakeTimers = Object.entries(timerAPI).some(
([name, func]) => func !== globalObj[name],
)

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

0 comments on commit f6a6eda

Please sign in to comment.