-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Support functional stateless components #45
Comments
Agreed this should definitely work out of the box. Thank you for the suggested workaround... I'm a bit surprised that this doesn't "just work" and would like to do a bit more research regarding what the "right" way to get this working with reagent would be. Do you know if |
Yes, it does work with
|
@geowarin ah. That trace is very helpful, thanks. I think we can get this fixed! |
Fixed in #53 |
I have a problem with that: using mount with a stateless component I get: Invariant Violation: Element appears to be neither ReactComponent nor DOMNode (keys: _currentElement,_rootNodeID,_instance,_pendingElement,_pendingStateQueue,_pendingReplaceState,_pendingForceUpdate,_renderedComponent,_context,_mountOrder,_topLevelWrapper,_pendingCallbacks,_mountIndex,_mountImage,_isOwnerNecessary,_warnedAboutRefsInRender) |
@gabrielenosso SFCs must return something, they can't return |
I know that they can't return null, so it isn't the problem. Thank you for your help! |
It gives me the problem when I use the .text() method. const Button = (props) => (
<div>
</div>
);
export default Button; import React from 'react';
import { mount } from 'enzyme';
import { expect } from 'chai';
import Button from './Button';
describe('Button', () => {
it('should render its label', () => {
const labelValue = 'labelValue';
expect(mount(<Button label={labelValue} />).text().indexOf(labelValue) >= 0).to.be.true;
});
}); |
@gabrielenosso interesting. I'll give this a try today. This could be a bug with the way |
Thanks for your support! :) |
Using 2.1.0 and looks like functionnal components dont work, or i dont use it correctly ? export const Test = () => <div>Test</div>;
let w = mount(<Test/>);
console.log(w.debug()); this outputs nothing... normal ? |
I am currently working on #261, and I have encountered a similar issue. Calling .text() directly on the wrapper does not work for stateless function components. I believe the issue can be traced to the use of findDOMNode. More information can be found here: facebook/react#4936. |
I found this issue because I was having problems with testing stateless functions as well:
I just wanted to follow the progress on this. |
Hello guys.
Thank you so much, reagent is exactly the lib I was waiting for!
I noticed that using
mount()
does not work on functional stateless components.There is a workaround: wrapping the function component with:
I would be nice if the lib did that automatically.
The text was updated successfully, but these errors were encountered: