diff --git a/config/polyfills.js b/config/polyfills.js index 673fb8399b4..8d97fb4ac39 100644 --- a/config/polyfills.js +++ b/config/polyfills.js @@ -22,3 +22,9 @@ require('whatwg-fetch'); // Object.assign() is commonly used with React. // It will use the native implementation if it's present and isn't buggy. Object.assign = require('object-assign'); + +// In tests, polyfill requestAnimationFrame since jsdom doesn't provide it yet. +// We don't polyfill it in the browser--this is user's responsibility. +if (process.env.NODE_ENV === 'test') { + require('raf').polyfill(global); +} diff --git a/package.json b/package.json index 2b793a35dab..1eedb9e99aa 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.6", "promise": "8.0.1", + "raf": "3.4.0", "react-dev-utils": "^4.1.0", "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4",