Skip to content
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

toMatchElement not respecting Arrays #186

Closed
vitreuz opened this issue Jan 12, 2018 · 2 comments
Closed

toMatchElement not respecting Arrays #186

vitreuz opened this issue Jan 12, 2018 · 2 comments

Comments

@vitreuz
Copy link

vitreuz commented Jan 12, 2018

It seems that as per the documentation toMatchElement is meant to match on props, however when the prop is an array it ignores the content.

Ex:

it("renders 5 0's", () => {
  const wrapper = shallow(<MyComponent />)

  expect(wrapper).toMatchElement(<MyRow row={[0, 0, 0, 0]} />)
);

This would successfully match on:

<MyRow row={["some", "random", "values"]} />
@blainekasten
Copy link
Collaborator

So, the logic for matching element is actually really simple. It just runs enzyme's debug() method and compares the strings.

I did a test and enzyme masks objects and arrays. This is unexpected, I thought it used to work..

Either way, I've got a ticket going with Enzyme to see where the fix lies: enzymejs/enzyme#1476

@blainekasten
Copy link
Collaborator

blainekasten commented Mar 1, 2018

I put up a PR in enzyme for this. So hopefully this will get fixed soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants