-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Getting a random hash for FocusRing in snaphots #2938
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
Comments
Did this start happening after updating React Spectrum to a specific version? Or updating Jest or React? I don't think there have been any recent changes to FocusRing. |
Looks related to the Parcel upgrade, might be linked to this issue as well #2881 I might try upgrading your Jest as Reid suggested. Or checking on your Jest config. Can you share more about those? |
I noticed this crop up around the same time as #2857 I locked to
So it seems to be an issue with more recent versions of the focus ring (or a dependency). |
I don't think you should be relying on the names of internal functions for your tests. These can change at any time. For example we might choose to refactor something. As long as the exported name that you import in your code is the same, it's not a breaking change. Not sure what to tell you about snapshot tests. We don't recommend them for exactly this reason: they are far too brittle and you may find yourself making trivial changes like this often. |
Another option you have is to Mock the components out of our library, then your snapshotting would actually be testing your code and wouldn't be dependent on ours. |
Closing for now. @dermyhughes feel free to let us know if the mock approach described above doesn't work. |
More a comment than anything, but I've noticed you get the hash on Reacts stacktrace too - not very friendly when debugging.
|
Same here. @devongovett |
🐛 Bug Report
I am using the FocusRing component to wrap around a button like so:
But recently our Jest snapshots tests have been rendering these with a random hashed string rather than the element name.
🤔 Expected Behavior
Previously these tests rendered the component name, just like the DOM:
😯 Current Behavior
Is this expected or has something changed?
The text was updated successfully, but these errors were encountered: