Look at Enzyme examples
bahmutov opened this issue ยท 3 comments
bahmutov commented
and its API methods and see how to recreate the same examples here
https://enzymejs.github.io/enzyme/
In particular look at
bahmutov commented
Interesting - abhinaba-ghosh/cypress-react-selector#23
bahmutov commented
Example: Enzyme's setProps
clones the component and re-renders it with new props
setProps(props, callback = undefined) {
if (this[ROOT] !== this) {
throw new Error('ReactWrapper::setProps() can only be called on the root');
}
if (arguments.length > 1 && typeof callback !== 'function') {
throw new TypeError('ReactWrapper::setProps() expects a function as its second argument');
}
const adapter = getAdapter(this[OPTIONS]);
this[UNRENDERED] = cloneElement(adapter, this[UNRENDERED], props);
this[RENDERER].render(this[UNRENDERED], null, () => {
this.update();
if (callback) {
callback();
}
});
return this;
}
export function cloneElement(adapter, el, props) {
return adapter.createElement(
el.type,
{ ...el.props, ...props },
);
}
which looks weird to me
bahmutov commented
๐ This issue has been resolved in version 4.12.0 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐