question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

requestAnimationFrame warnings on tests since React 16

See original GitHub issue

Is this a bug report?

Yes

Which terms did you search for in User Guide?

The issue is documented at https://facebook.github.io/react/docs/javascript-environment-requirements.html

Steps to Reproduce

  1. Start a project create-react-app project
  2. Try to run the template tests yarn test

Expected Behavior

I expected the testing to complete without warnings out-of-the-box (as it did pre-R16).

Actual Behavior

All tests pass, but prints message:

  console.error node_modules/fbjs/lib/warning.js:33
    Warning: React depends on requestAnimationFrame. Make sure that you load a polyfill in older browsers. http://fb.me/react-polyfills

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:60
  • Comments:36 (16 by maintainers)

github_iconTop GitHub Comments

93reactions
gaearoncommented, Sep 27, 2017

We’ll figure something out soon. Sorry about that. This was the biggest release we ever did, there’s also a new website we’re launching today, and between all that there’s a few kinks we still need to iron out.

45reactions
unutoiulcommented, Oct 12, 2017

Thanks for your quick replay, I just realised I met you at a meeting organised by Sapient Nitro in London.

My solution was to create

src/tempPolyfills.js

const raf = global.requestAnimationFrame = (cb) => {
  setTimeout(cb, 0)
}

export default raf

src/setupTests.js

import raf from 'tempPolyfills'
import Enzyme, { shallow, render, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import toJson from 'enzyme-to-json';

// React 16 Enzyme adapter
Enzyme.configure({ adapter: new Adapter() });

// Make Enzyme functions available in all test files without importing
global.shallow = shallow;
global.render = render;
global.mount = mount;
global.toJson = toJson;

// Fail tests on any warning
console.error = message => {
   throw new Error(message);
};

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

`requestAnimationFrame` polyfill error in Jest tests
Show activity on this post. Got this error after upgrading to React when I ran my Jest unit tests: React depends on requestAnimationFrame....
Read more >
requestAnimationFrame & polyfill in React 16
js:33 Warning: React depends on requestAnimationFrame. Make sure that you load a polyfill in older browsers. http://fb.me/react-polyfills Test ...
Read more >
Khrystyna Skvarok - Medium
Warning : React depends on requestAnimationFrame. ... You will anyway need it if you want to use Enzyme with React 16 (check Enzyme...
Read more >
Developers - requestAnimationFrame warnings on tests since React ...
Expected Behavior. I expected the testing to complete without warnings out-of-the-box (as it did pre-R16). Actual Behavior. All tests pass, but prints message ......
Read more >
requestAnimationFrame and polyfill in React 16
js:33 Warning: React depends on requestAnimationFrame. Make sure that you load a polyfill in older browsers. http://fb.me/react-polyfills Test ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found