-
Notifications
You must be signed in to change notification settings - Fork 85
test(ReactElementToJsxString): Add test when dealing with element inside prop object #312
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
test(ReactElementToJsxString): Add test when dealing with element inside prop object #312
Conversation
This comment has been minimized.
This comment has been minimized.
002c4ed
to
4a1922a
Compare
This comment has been minimized.
This comment has been minimized.
4a1922a
to
ab1b6a4
Compare
Hello @thomasbertet, thank you very much for your contribution. Unfortunately this test does not cover the issue in #307. As can be seen in this code snippet, the error only occurs if the React element to be transformed into a string was created by another React component. This is because React adds the "_owner" key to these elements pointing to the owning React component, which can cause an infinite loop. The unit tests are ran by Jest which is separate from the React lifecycle, thus elements created in the unit tests do not have the "_owner" key. This can be verified by (temporarily) commenting out the fix of #307 and then running the tests again. I'm not sure if we can properly test this using our current testing setup without using a virtual dom. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to suggestions on how to approach this.
Adding a virtual dom to the testing setup is possible, but this sounds like a very heavyweight solution for a single unit test.
Do you have other ideas?
Oh I see... I thought it was quite easier. Sorry about the misunderstanding. I could have done the check you did by commenting out the fix. |
This comment has been minimized.
This comment has been minimized.
…eally test sortObject fix
91af417
to
262221e
Compare
@PatrickSachs I added a proper test case for the issue. Please try it if you have time. Please tell me what you think, but IMHO this might be good enough :) |
Without having looked at the tests too much yet, I'm not a fan of adding this .spec.js file in a different directory than the other ones. I think the test either belongs in The tests fail and pass as expected, but I'll have a more in depth look at it. |
This comment has been minimized.
This comment has been minimized.
d984639
to
305e05b
Compare
@PatrickSachs I moved the test file. |
This looks good to me. Adding Enzyme for currently (just) a single unit tests is a big heavy, but I believe it will become useful for more tests in time. Unless any more issues crop up related to this I'll create a new release tomorrow. @samwalshnz |
Following issue #307 & PR #309
I added two tests:
Please tell me if anything is unclear or needs to follow certain rules. I tried to make them just as the others but I might have missed some.
@vvo Thanks for your time! Would love to see this fix released