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

find(Component|'selector') not working on conditionally rendered components. #2387

Open
2 of 13 tasks
shaleenmundra opened this issue Apr 22, 2020 · 0 comments
Open
2 of 13 tasks

Comments

@shaleenmundra
Copy link

shaleenmundra commented Apr 22, 2020

#1147 # Current behavior
I cannot find(Component|".selector") but I can see it via html() and via .contains()

code

<input type='text' name='Name'>

{isPasswordRequired && 
<input type='password' name='Password'>}

the isPasswordRequired value is set to true with a button click.

I simulated the button click and the boolean is set to true but still the .find() method is not able to find the given component.

test

//simulate button click
wrapper.update();

//works fine
wrapper.contains('input[name="Password"]'); 

// gives error .props() meant to be run on 1 node, 0 found instead.
wrapper.find('input[name="Password"]').props(); 

Expected behaviour

.contains(), .find() should return consistent results.

Your environment

MacOS mojave 10.14.6
node : v12.12.2
npm: 6.14.1

API

  • shallow
  • mount
  • render

Version

library version
enzyme 3.9.0
react 16.8.6
react-dom 16.8.6
react-test-renderer
adapter (below)

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-16.3
  • enzyme-adapter-react-16.2
  • enzyme-adapter-react-16.1
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )
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

1 participant