@testing-library/react
Advanced tools
Comparing version 14.0.0-alpha.2 to 14.0.0-alpha.3
@@ -173,2 +173,16 @@ 'use strict'; | ||
function jestFakeTimersAreEnabled() { | ||
/* istanbul ignore else */ | ||
if (typeof jest !== 'undefined' && jest !== null) { | ||
return ( | ||
// legacy timers | ||
setTimeout._isMockFunction === true || | ||
// modern timers | ||
// eslint-disable-next-line prefer-object-has-own -- No Object.hasOwn in all target environments we support. | ||
Object.prototype.hasOwnProperty.call(setTimeout, 'clock') | ||
); | ||
} // istanbul ignore next | ||
return false; | ||
} | ||
dom.configure({ | ||
@@ -185,3 +199,15 @@ unstable_advanceTimersWrapper: cb => { | ||
try { | ||
return await cb(); | ||
const result = await cb(); | ||
// Drain microtask queue. | ||
// Otherwise we'll restore the previous act() environment, before we resolve the `waitFor` call. | ||
// The caller would have no chance to wrap the in-flight Promises in `act()` | ||
await new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, 0); | ||
if (jestFakeTimersAreEnabled()) { | ||
jest.advanceTimersByTime(0); | ||
} | ||
}); | ||
return result; | ||
} finally { | ||
@@ -188,0 +214,0 @@ setIsReactActEnvironment(previousActEnvironment); |
@@ -145,2 +145,16 @@ import * as testUtils from 'react-dom/test-utils'; | ||
function jestFakeTimersAreEnabled() { | ||
/* istanbul ignore else */ | ||
if (typeof jest !== 'undefined' && jest !== null) { | ||
return ( | ||
// legacy timers | ||
setTimeout._isMockFunction === true || | ||
// modern timers | ||
// eslint-disable-next-line prefer-object-has-own -- No Object.hasOwn in all target environments we support. | ||
Object.prototype.hasOwnProperty.call(setTimeout, 'clock') | ||
); | ||
} // istanbul ignore next | ||
return false; | ||
} | ||
configure({ | ||
@@ -157,3 +171,15 @@ unstable_advanceTimersWrapper: cb => { | ||
try { | ||
return await cb(); | ||
const result = await cb(); | ||
// Drain microtask queue. | ||
// Otherwise we'll restore the previous act() environment, before we resolve the `waitFor` call. | ||
// The caller would have no chance to wrap the in-flight Promises in `act()` | ||
await new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, 0); | ||
if (jestFakeTimersAreEnabled()) { | ||
jest.advanceTimersByTime(0); | ||
} | ||
}); | ||
return result; | ||
} finally { | ||
@@ -160,0 +186,0 @@ setIsReactActEnvironment(previousActEnvironment); |
@@ -173,2 +173,16 @@ 'use strict'; | ||
function jestFakeTimersAreEnabled() { | ||
/* istanbul ignore else */ | ||
if (typeof jest !== 'undefined' && jest !== null) { | ||
return ( | ||
// legacy timers | ||
setTimeout._isMockFunction === true || | ||
// modern timers | ||
// eslint-disable-next-line prefer-object-has-own -- No Object.hasOwn in all target environments we support. | ||
Object.prototype.hasOwnProperty.call(setTimeout, 'clock') | ||
); | ||
} // istanbul ignore next | ||
return false; | ||
} | ||
dom.configure({ | ||
@@ -185,3 +199,15 @@ unstable_advanceTimersWrapper: cb => { | ||
try { | ||
return await cb(); | ||
const result = await cb(); | ||
// Drain microtask queue. | ||
// Otherwise we'll restore the previous act() environment, before we resolve the `waitFor` call. | ||
// The caller would have no chance to wrap the in-flight Promises in `act()` | ||
await new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, 0); | ||
if (jestFakeTimersAreEnabled()) { | ||
jest.advanceTimersByTime(0); | ||
} | ||
}); | ||
return result; | ||
} finally { | ||
@@ -188,0 +214,0 @@ setIsReactActEnvironment(previousActEnvironment); |
@@ -145,2 +145,16 @@ import * as React from 'react'; | ||
function jestFakeTimersAreEnabled() { | ||
/* istanbul ignore else */ | ||
if (typeof jest !== 'undefined' && jest !== null) { | ||
return ( | ||
// legacy timers | ||
setTimeout._isMockFunction === true || | ||
// modern timers | ||
// eslint-disable-next-line prefer-object-has-own -- No Object.hasOwn in all target environments we support. | ||
Object.prototype.hasOwnProperty.call(setTimeout, 'clock') | ||
); | ||
} // istanbul ignore next | ||
return false; | ||
} | ||
configure({ | ||
@@ -157,3 +171,15 @@ unstable_advanceTimersWrapper: cb => { | ||
try { | ||
return await cb(); | ||
const result = await cb(); | ||
// Drain microtask queue. | ||
// Otherwise we'll restore the previous act() environment, before we resolve the `waitFor` call. | ||
// The caller would have no chance to wrap the in-flight Promises in `act()` | ||
await new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, 0); | ||
if (jestFakeTimersAreEnabled()) { | ||
jest.advanceTimersByTime(0); | ||
} | ||
}); | ||
return result; | ||
} finally { | ||
@@ -160,0 +186,0 @@ setIsReactActEnvironment(previousActEnvironment); |
@@ -48,2 +48,16 @@ "use strict"; | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function jestFakeTimersAreEnabled() { | ||
/* istanbul ignore else */ | ||
if (typeof jest !== 'undefined' && jest !== null) { | ||
return ( | ||
// legacy timers | ||
setTimeout._isMockFunction === true || | ||
// modern timers | ||
// eslint-disable-next-line prefer-object-has-own -- No Object.hasOwn in all target environments we support. | ||
Object.prototype.hasOwnProperty.call(setTimeout, 'clock') | ||
); | ||
} // istanbul ignore next | ||
return false; | ||
} | ||
(0, _dom.configure)({ | ||
@@ -60,3 +74,15 @@ unstable_advanceTimersWrapper: cb => { | ||
try { | ||
return await cb(); | ||
const result = await cb(); | ||
// Drain microtask queue. | ||
// Otherwise we'll restore the previous act() environment, before we resolve the `waitFor` call. | ||
// The caller would have no chance to wrap the in-flight Promises in `act()` | ||
await new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, 0); | ||
if (jestFakeTimersAreEnabled()) { | ||
jest.advanceTimersByTime(0); | ||
} | ||
}); | ||
return result; | ||
} finally { | ||
@@ -63,0 +89,0 @@ (0, _actCompat.setReactActEnvironment)(previousActEnvironment); |
{ | ||
"name": "@testing-library/react", | ||
"version": "14.0.0-alpha.2", | ||
"version": "14.0.0-alpha.3", | ||
"description": "Simple and complete React DOM testing utilities that encourage good testing practices.", | ||
@@ -85,2 +85,4 @@ "main": "dist/index.js", | ||
"testing-library/no-unnecessary-act": "off", | ||
"testing-library/prefer-explicit-assert": "off", | ||
"testing-library/prefer-find-by": "off", | ||
"testing-library/prefer-user-event": "off" | ||
@@ -87,0 +89,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5284882
34736