-
Notifications
You must be signed in to change notification settings - Fork 47.7k
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
TestUtils cannot render stateless function components #5901
Comments
Duplicate of #5455 |
@jimfb I'm not sure this is necessarily a duplicate. This is specific to the TestUtils render, not necessarily refs at the end of that ticket chain you mentioned above. I'm currently having this issue with Phantom + Mocha. |
@antgonzales did you manage to overcome this problem somehow? |
@thealjey I moved over to Jest/JSDOM/Enzyme, I bet this issue isn't a problem in a Jest/JSDOM environment. Happy to give it a test if you're seeing this issue in that environment or a Mocha/JSDOM environment. |
I'm using react 14.3, babel 6.0.15 and react test utils addon 0.14.6 . Jasmine 2.3 is my testing framework of choice.
It seems as though any stateless function component cannot be tested by TestUtils.renderIntoComponent or TestUtils.createRenderer().render(). Either returns null when rendering the function component.
Test with any stateless function component and it should yield the same result.
Component:
import React from 'react';
const User = ({name, age}) => ( return <div>{name}, {age}</div> );
module.exports = User;
Test:
expect(TestUtils.renderIntoDocument(<User name={"bob"} age={20} />)).toBeTruthy();
Error:
Expected null to be truthy.
The text was updated successfully, but these errors were encountered: