A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://enzymejs.github.io/enzyme/docs/api/ShallowWrapper/matchesElement.html below:

matchesElement(node) ยท Enzyme

.matchesElement(patternNode) => Boolean

Returns whether or not a given react element patternNode matches the wrapper's render tree. It must be a single-node wrapper, and only the root node is checked.

The patternNode acts like a wildcard. For it to match a node in the wrapper:

Arguments
  1. patternNode (ReactElement): The node whose presence you are detecting in the wrapper's single node.
Returns

Boolean: whether or not the current wrapper match the one passed in.

Example
class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.handleClick = this.handleClick.bind(this);
  }

  handleClick() {
    
  }

  render() {
    return (
      <button type="button" onClick={this.handleClick} className="foo bar">Hello</button>
    );
  }
}

const wrapper = shallow(<MyComponent />);
expect(wrapper.matchesElement(<button>Hello</button>)).to.equal(true);
expect(wrapper.matchesElement(<button className="foo bar">Hello</button>)).to.equal(true);
Common Gotchas

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4