Run react-dom SSR import test in jsdom-less environment (#13157)

This commit is contained in:
Dan Abramov
2018-07-06 16:43:43 +01:00
committed by GitHub
parent 6f6b560a64
commit f762b3abb1
3 changed files with 40 additions and 41 deletions

View File

@@ -7,24 +7,6 @@ if (NODE_ENV !== 'development' && NODE_ENV !== 'production') {
global.__DEV__ = NODE_ENV === 'development';
global.__PROFILE__ = NODE_ENV === 'development';
global.requestAnimationFrame = function(callback) {
setTimeout(callback);
};
global.requestIdleCallback = function(callback) {
return setTimeout(() => {
callback({
timeRemaining() {
return Infinity;
},
});
});
};
global.cancelIdleCallback = function(callbackID) {
clearTimeout(callbackID);
};
// By default React console.error()'s any errors, caught or uncaught.
// However it is annoying to assert that a warning fired each time
// we assert that there is an exception in our tests. This lets us
@@ -34,7 +16,25 @@ global.cancelIdleCallback = function(callbackID) {
Error.prototype.suppressReactErrorLogging = true;
if (typeof window !== 'undefined') {
// Same as above.
global.requestAnimationFrame = function(callback) {
setTimeout(callback);
};
global.requestIdleCallback = function(callback) {
return setTimeout(() => {
callback({
timeRemaining() {
return Infinity;
},
});
});
};
global.cancelIdleCallback = function(callbackID) {
clearTimeout(callbackID);
};
// Same as we did with Error.prototype above.
DOMException.prototype.suppressReactErrorLogging = true;
// Also prevent JSDOM from logging intentionally thrown errors.