Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: requestAnimationFrame is not defined #185

Closed
markbrown4 opened this issue May 10, 2017 · 7 comments
Closed

ReferenceError: requestAnimationFrame is not defined #185

markbrown4 opened this issue May 10, 2017 · 7 comments

Comments

@markbrown4
Copy link

markbrown4 commented May 10, 2017

Version

1.3.0

I'm using mocha / enzyme / jsdom to run tests which incude the <Typeahead> and am getting

ReferenceError: requestAnimationFrame is not defined at Object.componentDidMount (node_modules/react-bootstrap-typeahead/lib/Overlay.react.js:71:37)

I tried faking it with global.requestAnimationFrame = function(cb) { cb(0) } but looks like there's other issues, the test just hangs and I haven't found the cause yet.

I haven't found a version of jsdom which polyfills requestAnimationFrame, have you got a test using these packages to work? The previous versions of the package did run correctly.

There's also three warnings from this package:

Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references to remove this warning.
Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.
Warning: Portal: React.createClass is deprecated and will be removed in version 16. Use plain JavaScript classes instead. If you're not yet ready to migrate, create-react-class is available on npm as a drop-in replacement.

@ericgio
Copy link
Owner

ericgio commented May 10, 2017

The use of requestAnimationFrame was added in v1.3.0 to help smooth out scrolling. I don't currently have a working test for it, so I don't have a helpful answer for you at the moment.

There's also three warnings from this package:

Thanks. This is being tracked in #168 and should be fixed by #181. I just haven't had time to merge yet.

@markbrown4
Copy link
Author

requestAnimationFrame is just one issue, I tried running my test suite against all of the 1.x.x releases and couldn't get any of them to run with these packages so I'm back to 0.10.4.

    "react": "^15.3.1",
    "react-bootstrap": "^0.30.3",
    "react-bootstrap-typeahead": "^0.10.4",
    "enzyme": "^2.4.1",
    "jsdom": "9.12.0",
    "mocha": "^2.5.3"

@ericgio
Copy link
Owner

ericgio commented May 11, 2017

If you can post a test repo, I'll try to take a look when I have some time.

@joaoreynolds
Copy link

following so I can upgrade to 1.3.0 when this is resolved. Thanks!

@ozzyogkush
Copy link

ozzyogkush commented Jun 22, 2017

I am seeing this as well using 1.4.0 with Mocha/Chai and ReactTestUtils.renderIntoDocument()

@ericgio
Copy link
Owner

ericgio commented Jul 19, 2017

If someone can provide a test case that would help. Otherwise there's not much I can do here.

@ericgio
Copy link
Owner

ericgio commented Jul 28, 2017

After some further investigation, I'm going to close this out, since it's not an issue with the typeahead library itself. As noted in the original post, jsdom doesn't provide requestAnimationFrame, so you need to polyfill the test environment yourself. Given that everyone's test environment is a bit different, it's beyond scope for me to figure out how to do that.

Further discussion: jestjs/jest#1644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants