-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Mount find() Does Not Find Rendered Marker #1233
Comments
Can you share the code that contains the class name? |
yes I can share temporarily https://gist.github.com/dschinkel/e1e58c1cbdc60962078e1afe21cffe4b |
the same for me:
I'm getting
but |
@ljharb @3axap4eHko yea exactly... I feel like mount() isn't able to dig down the entire app tree..? Iike the behavior I feel I've noticed is that it sorta stops 2-3 children down.. |
@dschinkel how is |
@aweary any chance this is an issue with the RST selector parser? |
@ljharb element.findWhere(node => node.hasClass('.feature__cover')) If it doesn't, can you verify if |
@ljharb hehe yea let me show you that one...from this other 1000 line fing container (going from from 1 100 line container to another 1000 container :) might be why mount() doesn't work, too much freakin code in a container). https://gist.github.com/dschinkel/8d176d9abc19f9cbe39d5a4d6edc2c43 |
interesting @aweary I get this in the console when I tried your route: this printed to the console: |
@dschinkel sorry my mistake, remove the leading |
nope, got to the same result, not found :( but thanks. I mean when you're dealing with 2 1000 line containers, Um...who knows with that kind of rabbit hole. :(. I do know that the code that had my feature marker was indeed hit. |
@dschinkel can you verify if it's traversing the node you're looking for? You can try just logging out |
output / rabbit hole does show it:
full output: Note: I've also tried searching related (I've had this issue before, never resolved it) #1197 (comment) btw: accidentally hit the close button, reopened the post. |
this is crazy. I think I'm losing my mind. I've never had this problem in other projects (not that I recall) or at least this is the first time I've been having these issues.. Here is a test for another part in the same project but on a different container (different from the code I posted) but shows the weirdness I've been having as well in this example: |
sorry I missed this @aweary:
let me check.. |
@aweary Per this:
This shows it's traversing that node (New Cast) also I'm not using an enzyme adapter, never have, is that something new? In our case we're running React 15.1, do I need Our current versions and what is installed are the following:
|
@aweary it does not work also. I use |
@dschinkel sorry I assumed you were using Enzyme 3. The adapters are part of the rewrite, check out the migration guide. We fixed a number of selector parsing issues in the rewrite, and this could be related to one of them.
You would use At this point, it's going to be difficult for me to help further without a small, succinct example reproducing the issue that I can run locally and investigate. |
ah ok I thought I was on the up and up...apparently my head is too buried in enzyme code. I didn't realize there was a rewrite recently. Thanks I'll try it out and report back!! Thanks for you help so far @aweary @ljharb Without having to look too much when was this rewrite done? I tried installing Enzyme 3 the other day along with updating chai-enzyme, but got chai-enzyme errors which I believe is now being fixed...there's an issue for it in chai-enzyme where it was blowing up on me and someone was already working on a fix for that so I had to revert back to enzyme <3 Looks like I actually need |
hmm we're using React 15.1, not sure if the team wants to be upgrading react right now (not my call)
Then tried to run tests and got: |
@aweary I'm using |
This is what I found <div class="feature">
<div class="feature__cover">
<div class="feature__media">Episode</div>
</div>
<div class="feature__details"><h3 class="feature__type">episode</h3>
<div class="feature__title"></div>
</div>
</div> but Quite different JSON[
{
"nodeType": "host",
"type": "div",
"props": {
"className": "feature",
"children": [
{
"type": "div",
"key": null,
"ref": null,
"props": {
"className": "feature__cover",
"children": {
"key": null,
"ref": null,
"props": {
"feature": {
"id": "169934",
"series_id": "SH015468900000",
"style": "S",
"call_to_action": "WATCH THE TRAILER",
"call_to_action_override_long": "",
"image_url": true,
"subheading": "",
"suppress_season_number_episode_number": false
}
},
"_owner": null,
"_store": {}
}
},
"_owner": null,
"_store": {}
},
{
"type": "div",
"key": null,
"ref": null,
"props": {
"className": "feature__details",
"children": [
{
"type": "h3",
"key": null,
"ref": null,
"props": {
"className": "feature__type",
"children": "episode"
},
"_owner": null,
"_store": {}
},
{
"type": "div",
"key": null,
"ref": null,
"props": {
"className": "feature__title"
},
"_owner": null,
"_store": {}
}
]
},
"_owner": null,
"_store": {}
}
]
},
"key": null,
"ref": null,
"instance": null,
"rendered": [
{
"nodeType": "host",
"type": "div",
"props": {
"className": "feature__cover",
"children": {
"key": null,
"ref": null,
"props": {
"feature": {
"id": "169934",
"series_id": "SH015468900000",
"style": "S",
"call_to_action": "WATCH THE TRAILER",
"call_to_action_override_long": "",
"image_url": true,
"subheading": "",
"suppress_season_number_episode_number": false
}
},
"_owner": null,
"_store": {}
}
},
"key": null,
"ref": null,
"instance": null,
"rendered": {
"nodeType": "function",
"props": {
"feature": {
"id": "169934",
"series_id": "SH015468900000",
"style": "S",
"call_to_action": "WATCH THE TRAILER",
"call_to_action_override_long": "",
"image_url": true,
"subheading": "",
"suppress_season_number_episode_number": false
}
},
"key": null,
"ref": null,
"instance": null,
"rendered": null
}
},
{
"nodeType": "host",
"type": "div",
"props": {
"className": "feature__details",
"children": [
{
"type": "h3",
"key": null,
"ref": null,
"props": {
"className": "feature__type",
"children": "episode"
},
"_owner": null,
"_store": {}
},
{
"type": "div",
"key": null,
"ref": null,
"props": {
"className": "feature__title"
},
"_owner": null,
"_store": {}
}
]
},
"key": null,
"ref": null,
"instance": null,
"rendered": [
{
"nodeType": "host",
"type": "h3",
"props": {
"className": "feature__type",
"children": "episode"
},
"key": null,
"ref": null,
"instance": null,
"rendered": "episode"
},
{
"nodeType": "host",
"type": "div",
"props": {
"className": "feature__title"
},
"key": null,
"ref": null,
"instance": null,
"rendered": null
}
]
}
]
}
] |
I wouldn't rely on the JSON version of What about |
It's hard to know if there are actually issues with v3, or if they're solely with the React 16 adapter, because people for some reason are upgrading to enzyme 3 and react 16 at the same time. If you stick with React 15, and upgrade to v3, and follow the migration guide, you should be fine. |
It looks like it does not traverse over subcomponents imported from other files |
@3axap4eHko which, |
@dmccown1500 I also had a similar issue, seems like redux and enzyme not working properly.
|
@sadu thanks for the tip. Had similar issue - |
This needs to be reopened. This is still a problem. |
@msafi this specific issue was in v2; could you file a new issue if you're seeing problems in v3? |
Just tried with Enzyme 3. This is no longer an issue. Thank you! |
I just encountered this issue with redux and enzyme 3.3.0, the |
I'm having this issue. Enzyme 3.3.0 with MobX. HTML is correct but |
Can confirm with versions:
when the component being tested must be wrapped by a redux Provider:
then |
@github-account-because-they-want-it MobX isn't compatible with enzyme with a react adapter; you'd need a mobx adapter. Are you using one? |
if noone if seeing the same results from |
Confirmed again:
I'm not using Redux. |
@dmccown1500 The update works great! |
still an issue but calling update() before using stuff like find() works |
still an issue and in my situation even I'm testing a method that does DOM manipulation like creating and appending DOMs to an element that I pass as argument:
the test looks like:
|
Manually manipulating the DOM isn't really something that's idiomatic in React, and it wouldn't surprise me if you ran into issues doing that with jsdom. Please file a new issue if you think there's an issue with enzyme. |
For me the problem with .find() was because of wrapping a component with <React.Fragment>. Changed it back to and that did the trick. Seems like Enzyme 3.3.0 doesn't like React.Fragment
|
@EvgenyW3 see #1213; fragments aren't currently supported. |
@StefanoSega I had a similar problem. I have a component written in pure JS that inserts html inside React component. After component mount, I'm using render method before find and it works as expected. Example:
|
meet with the same problem. html() is right but find couldn't find the dom. update() doesn't help. |
Using |
I wouldn't recommend using |
This is a better workaround as opposed to comparing html output. enzymejs/enzyme#1233
* test: refactor github organism test code with `.update()` This is a better workaround as opposed to comparing html output. enzymejs/enzyme#1233 * test: change github user highlight tests to `.update()` workaround * test: add unit tests for app page component
still happened for me(I was also updating to React 16 and Enzyme all at once). If you guys still wonder why people do that, it's because I updated to React 16, and then realized Enzyme has to be updated as well.. I guess for most people there's no reason to update enzyme alone if all is working :) In any case, wrapper.update() solved it for me, wrapper.html() was showing the right DOM, but wrapper.find(...) was failing |
@IamTheHttp you should absolutely downgrade back to react 15, upgrade to enzyme 3 and get everything passing, and then update to react 16. |
This wont allow me to simulate click. |
This one is pretty frustrating. I mount this container. It does hit the code I expect that contains my css feature marker (
ft-playback-error
). But in the end I end up with not found.screencast of this issue: https://youtu.be/kh-UJTig3Qg
message.nodes ends up being 0 (or aka not found). Why?

I assumed when you mounted, it runs every child's render() (every child that's being hit down the codepath of container..obviously depending on whatever logic is in its render will determine which children are being rendered) method of this container.
The text was updated successfully, but these errors were encountered: