Hello,
We are using Jest snapshots with Victory and are having trouble with snapshots being constantly outdated due to the id attributes of the Clip Path being a randomly generated "magic number".
The offending line appears to be here: https://github.com/FormidableLabs/victory-core/blob/master/src/victory-clip-container/victory-clip-container.js#L38
The jest docs are clear about the problem:
Your tests should be deterministic. That is, running the same tests multiple times on a component that has not changed should produce the same results every time. You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic data.
https://facebook.github.io/jest/docs/en/snapshot-testing.html#tests-should-be-deterministic
one solution would be to accept clipID prop or even a makeClipID function prop that could allow mocking the clipID
This is also an issue when using SSR:
warning.js?f22e485:36 Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
(client) "164"><clipPath id="9553" data-reactid="
(server) "164"><clipPath id="5227" data-reactid="
Sorry about that, I will add an optional clipId prop
Most helpful comment
one solution would be to accept
clipIDprop or even amakeClipIDfunction prop that could allow mocking the clipID