question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

component.prop("id") returned with component.find("#foo")

See original GitHub issue

Is this a bug report?

Yes

Environment

enzyme@3.0.0

Steps to Reproduce

When a component is mounted with JSDOM the selector library does not differentiate props.id and element.id

using react router as an example

const test = mount(<Link id="foo" />)
const fooLink = test.find("#foo) <-- returns 2 nodes (<Link /> + <a>)

Expected Behavior

I would not expect a custom component with the prop id to be returned when querying with a CSS selector.

  • test.findWhere(n => n.prop("id") === foo) <-- expect to return 2 nodes
  • test.find("#foo") <-- expect to return a single node

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
conartist6commented, Nov 16, 2018

I have opened #1907 for the problems which occur regardless of this issue.

0reactions
conartist6commented, Nov 16, 2018

Perhaps all that needs to be done is for there to be a convenience API, something like findHost which was a shortcut for hostNodes().find() At least having such a thing be present in documentation would give it more visibility and allow the find documentation to call out the circumstance in which using it would be appropriate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

component.prop("id") returned with component.find("#foo")
I would not expect a custom component with the prop id to be returned when querying with a CSS selector. test.findWhere(n => n.prop("id")...
Read more >
How to get "key" prop from React element (on change)?
You will need to pass value in key as a different prop. From docs: Keys serve as a hint to React but they...
Read more >
Props | Vue.js
When objects and arrays are passed as props, while the child component cannot mutate the prop binding, it will be able to mutate...
Read more >
React — Dynamic Component Names with JSX - Medium
Attempting to set the tag name (directly) via a general expression. This wont work and will cause a compiler error. render() { return...
Read more >
Passing Functions to Components - React
There are several ways to make sure functions have access to component attributes like this.props and this.state , depending on which syntax and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found