Skip to content

Commit

Permalink
Include requestAnimationFrame polyfill for React 16
Browse files Browse the repository at this point in the history
See jestjs/jest#4545 for more info.
  • Loading branch information
cweiss-stripe committed Sep 28, 2017
1 parent 95d77ab commit 26bd35b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {configure, shallow} from 'enzyme';
import Button from './Button';

configure({adapter: new Adapter()});
window.requestAnimationFrame = fn => setTimeout(fn, 0);

describe('Button Component', () => {
it('should contain the right text', () => {
Expand Down
1 change: 1 addition & 0 deletions inject.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {configure, shallow} from 'enzyme';
import inject from './inject';

configure({adapter: new Adapter()});
window.requestAnimationFrame = fn => setTimeout(fn, 0);

describe('inject HOC', () => {
it('should add "newProp"', () => {
Expand Down
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
setupFiles: ['./utils/raf.js'],
};
3 changes: 3 additions & 0 deletions utils/raf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global.requestAnimationFrame = callback => {
setTimeout(callback, 0);
};

0 comments on commit 26bd35b

Please sign in to comment.