-
-
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
[Improved Fiber Support] Support Array-rendering components #1149
Comments
I noticed that all my I found this a little confusing since at first I wasn't sure if I set up my Array returns properly, some sort of temporary error message from Enzyme about this being unsupported would be helpful. |
👍🏼 |
FYI wrapping code with |
@udivankin Nice but we have to migrate to React 16.2 to be able to use this new API :/ |
And |
Does not work |
const wrapper = shallow(<MyComponent />);
console.log(
wrapper.debug(),
wrapper.children().debug(),
); log output: <Symbol(react.fragment)>
<PaymentIcon amount="$10.00" displayName="John Jingleheimer" type="card" size="huge" />
<Header as="h4" content={[undefined]} />
</Symbol(react.fragment)>
<PaymentIcon amount="$10.00" displayName="John Jingleheimer" type="card" size="huge" />
<Header as="h4" content={[undefined]} /> Which is exactly what I expect. |
Just to clarify for people like me, if using at least React V16.2, i.e. the following does not work (using enzyme 3.3.0):
This works:
|
@lelandrichardson This issue has turned into a blocker for my team, and I'd love to help resolve it.
|
|
@ljharb Thanks for the quick reply! Could you explain the purpose of I'm happy to take a crack at it, but I need a little more context. I've read through some of the other adapters, but it's difficult to understand the purpose of some of the exposed methods. |
nodeToHostNode, not nodeToHostName - the purpose is to take an RST node, and return the "host node" - ie, the HTML DOM node. |
I think I have a workable solution to this problem. I rewrote
Will this approach work in all required instances? Did I miss something here? How should I go about testing this? |
I'm not sure or not :-) we'd need to add extensive test cases for both shallow and mount, for as many wrapper methods as possible. |
I don't like adding import React, { Fragment } from 'react';
import { shallow } from 'enzyme';
const classNames = ['first-div', 'second-div'];
const MyComponent = () => classNames.map((cn) => <div className={cn} />);
describe('<MyComponent />', () => {
it('should render a div with class first-div', () => {
const wrapper = shallow(<MyComponent />);
expect(wrapper.at(0).hasClass('first-div')).toBe(true);
});
}); --Edit: Another example; You can wrap the import React, { Fragment } from 'react';
import { shallow } from 'enzyme';
const classNames = ['first-div', 'second-div'];
const MyComponent = () => classNames.map((cn) => <div className={cn} />);
describe('<MyComponent />', () => {
it('should render a div with class first-div', () => {
const divs = shallow(<MyComponent />);
const wrapper = shallow(<div>{divs}</div>);
expect(wrapper.find('div').length).toBe(2);
});
}); |
I believe we still have a little bit of work to do on this front.
The text was updated successfully, but these errors were encountered: