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.

Generated UUID in 4.0.5 breaks snapshot testing

See original GitHub issue

This commit https://github.com/wwayne/react-tooltip/commit/78e3c2be784f2b96d8bb888b81785b2b38179dae added generateUUID, which generates a random UUID every time a tooltip is rendered, which changes Jest snapshots every time they’re run.

That commit was done in https://github.com/wwayne/react-tooltip/pull/559, which says “No changes in workflows or documentation”, which, while true, apparently didn’t take into account changes in the DOM and testing. I would recommend a solution without the uuid state, if possible, but if not, some override that would disable the UUID in testing

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
tom1700commented, Apr 3, 2020

So it’s not nice but it works:

jest.mock('crypto', () => ({
  randomBytes: (num: number) => new Array(num).fill(0),
}));

With this my classNames look like:

__react_component_tooltip t00000000-0000-4000-8000-000000000000
3reactions
wwaynecommented, Apr 2, 2020

🎉 This issue has been resolved in version 4.1.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generated UUID in 4.0.5 breaks snapshot testing #562 - GitHub
This commit 78e3c2b added generateUUID , which generates a random UUID every time a tooltip is rendered, which changes Jest snapshots every ...
Read more >
How to mock uuid with Jest - Stack Overflow
Mock it by using mockImplementation . import uuid from 'uuid/v4'; jest.mock('uuid/v4'); describe('mock uuid', () => { it('should return ...
Read more >
Snapshot Testing - Jest
Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.
Read more >
jest uuid syntaxerror: unexpected token 'export' - You.com
I can't get my tests to run. When I run 'yarn test' for my react app, I get the dreaded error: Jest encountered...
Read more >
The Grails Framework 4.0.5
2.9Testing an Application. 2.10Deploying an Application. 2.11Supported Java EE Containers. 2.12Creating Artefacts. 2.13Generating an Application.
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