File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Expand file tree Collapse file tree 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
55
66// Currently this fn only supports jest timers, but it could support other test runners in the future.
77function 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+ }
1213
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+ )
1520}
1621
1722function runWithJestRealTimers ( callback ) {
@@ -50,13 +55,10 @@ function runWithJestRealTimers(callback) {
5055}
5156
5257function 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
6062}
6163
6264// 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