cypress-io/cypress-react-unit-test

Look at Enzyme examples

Closed this issue ยท 3 comments

and its API methods and see how to recreate the same examples here

https://enzymejs.github.io/enzyme/

In particular look at

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

๐ŸŽ‰ This issue has been resolved in version 4.12.0 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€