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

Option to have a prop ignored on contains #273

Closed
DanielMSchmidt opened this issue Mar 19, 2016 · 3 comments
Closed

Option to have a prop ignored on contains #273

DanielMSchmidt opened this issue Mar 19, 2016 · 3 comments

Comments

@DanielMSchmidt
Copy link

Hi there,

First of all thanks for this great library! I am currently testing a React Native application and I found it hard to do so, as contains can't be differed to be more allowing.

My use case is that I have a component render a <Text> element which is set via prop, much like in your example test. Unfortunately my element needs a style prop, which I don't intend to share between my tests and application. Would it be possible to add a whitelist to the compare functions as additional argument? I would be glad to help and do a PR if this feature is chosen to be useful for anyone else.

Have a nice day!

@griffinmichl
Copy link
Contributor

I also found this a bit counter intuitive my first time using enzyme. I currently use the approach below when I want to test the contents of an element independent of its props.

  it('should render text inside the Text component', () => {
    const text = 'Test Text';
    const wrapper = shallow(
      <Button text={text} />
    );

    expect(wrapper.find(Text).prop('children')).to.equal(text);
  });

@smacker
Copy link
Contributor

smacker commented Mar 21, 2016

same idea: #204 (comment) :)

@aweary
Copy link
Collaborator

aweary commented May 10, 2016

The new API introduced in #362 should cover this use case, so I'm going to close this as it seems resolved. Let me know if you have any questions!

@aweary aweary closed this as completed May 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants