enzyme: Enzyme 3 - Find Where does not work.
Hi, after update to v3, findWhere stopped working.
Following line throws Method “props” is only meant to be run on a single node. 0 found instead.
wrapper.findWhere(w => w.prop('content') === 'Register').simulate('click')
This is the wrapper.debug() - shortened
<Segment inverted={true}>
...
<Button type="button" onClick={[Function]} color="green" labelPosition="left" content="Register" icon="sign in" as="button">
<button type="button" className="ui green icon left labeled button" disabled={[undefined]} onClick={[Function]} role="button" tabIndex={[undefined]}>
<Icon name="sign in" as="i">
<i aria-hidden="true" className="sign in icon" />
</Icon>
Register
</button>
</Button>
...
</Segment>
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 9
- Comments: 20 (9 by maintainers)
Thanks for looking into it. Based on a suggestion above, I have gotten it working using
The code that creates the wrapper is here:
The component I was trying to find is here: https://github.com/getsentry/sentry/blob/master/src/sentry/static/sentry/app/components/confirm.jsx
So, it seems to be working fine using a two step
.find
then.filterWhere
rather than a straight.findWhere
using a two-part boolean expression (n.type === 'Confirm' && n.contains('....')
).Getting the same thing, I’m using
mount
:react@16.0.0 enzyme@3.0.0
Jest setup file: