Skip to content

Commit c9ea562

Browse files
authored
Polyfill rAF in test environment (facebook#3340)
1 parent 6ca9a5f commit c9ea562

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

config/polyfills.js

+6
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ require('whatwg-fetch');
2222
// Object.assign() is commonly used with React.
2323
// It will use the native implementation if it's present and isn't buggy.
2424
Object.assign = require('object-assign');
25+
26+
// In tests, polyfill requestAnimationFrame since jsdom doesn't provide it yet.
27+
// We don't polyfill it in the browser--this is user's responsibility.
28+
if (process.env.NODE_ENV === 'test') {
29+
require('raf').polyfill(global);
30+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"postcss-flexbugs-fixes": "3.2.0",
4949
"postcss-loader": "2.0.6",
5050
"promise": "8.0.1",
51+
"raf": "3.4.0",
5152
"react-dev-utils": "^4.1.0",
5253
"style-loader": "0.19.0",
5354
"sw-precache-webpack-plugin": "0.11.4",

0 commit comments

Comments
 (0)