`requestAnimationFrame` polyfill error in Jest tests `requestAnimationFrame` polyfill error in Jest tests reactjs reactjs

`requestAnimationFrame` polyfill error in Jest tests


Found a workaround!

Steps:

  1. Create the file __mocks__/react.js
  2. Add the following into __mocks__/react.js

const react = require('react');// Resolution for requestAnimationFrame not supported in jest error :// https://github.com/facebook/react/issues/9102#issuecomment-283873039global.window = global;window.addEventListener = () => {};window.requestAnimationFrame = () => {  throw new Error('requestAnimationFrame is not supported in Node');};module.exports = react;