File tree 1 file changed +15
-13
lines changed
1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,18 @@ const TEXT_NODE = 3
5
5
6
6
// Currently this fn only supports jest timers, but it could support other test runners in the future.
7
7
function runWithRealTimers ( callback ) {
8
- // istanbul ignore else
9
- if ( typeof jest !== 'undefined' ) {
10
- return runWithJestRealTimers ( callback ) . callbackReturnValue
11
- }
8
+ return hasJestTimers ( )
9
+ ? runWithJestRealTimers ( callback ) . callbackReturnValue
10
+ : // istanbul ignore next
11
+ callback ( )
12
+ }
12
13
13
- // istanbul ignore next
14
- return callback ( )
14
+ function hasJestTimers ( ) {
15
+ return (
16
+ typeof jest !== 'undefined' &&
17
+ jest !== null &&
18
+ typeof jest . useRealTimers === 'function'
19
+ )
15
20
}
16
21
17
22
function runWithJestRealTimers ( callback ) {
@@ -50,13 +55,10 @@ function runWithJestRealTimers(callback) {
50
55
}
51
56
52
57
function jestFakeTimersAreEnabled ( ) {
53
- // istanbul ignore else
54
- if ( typeof jest !== 'undefined' ) {
55
- return runWithJestRealTimers ( ( ) => { } ) . usedFakeTimers
56
- }
57
-
58
- // istanbul ignore next
59
- return false
58
+ return hasJestTimers ( )
59
+ ? runWithJestRealTimers ( ( ) => { } ) . usedFakeTimers
60
+ : // istanbul ignore next
61
+ false
60
62
}
61
63
62
64
// we only run our tests in node, and setImmediate is supported in node.
You can’t perform that action at this time.
0 commit comments