-
Notifications
You must be signed in to change notification settings - Fork 221
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
Generate stable IDs #664
Comments
@matsprea Thanks for the issue. Can you add a bit more context or a code block? I'm curious if mocking Also, which components are you specifically talking about? Some components have a manual id override like We're not closed to the idea entirely but some more context about the pain point would help us a ton! |
My specific issue is with the `NotificationsPopup > › NotificationsPopup > › snapshot with open set to true
As a workaround we are mocking the Id in the test
but we would like to have it generated in a predictable/stable way or control how it's generated. |
Thank you for creating this issue! I'd like to add a few notes to guide how we can improve this.
My suggestion is we create a utility function that will go into |
Thanks @NicholasBoll , that will be awesome! |
Our current id generation has issues. - It generates very long ids that add noise to the page - It is possible to generate a blank id - Id generation is slow - Snapshot tests require mocking the `uuid` module Fixes: #1311, #1106, #664, #602 [category:Hooks] Release Note: **NOTE for jest snapshots**: This change removes the `uuid` package and instead will generate a one-time client seed and then create auto-incrementing ids. This change will not break UI or automated UI tests. It will break snapshot tests however. Previously, the only way to get stable ids for snapshot tests was to mock the `uuid` module. This was an implementation detail. To make snapshots work again, add the following to your jest setup file: ```ts import {setUniqueSeed, resetUniqueIdCount} from '@workday/canvas-kit-react/common'; beforeEach(() => { setUniqueSeed('a'); // force set the seed resetUniqueIdCount(); // reset the unique id count }); ``` This will ensure each Jest snapshot has ids that look like `a0` and `a1` and will be the same every time the snapshot is run. Do not use these methods in production though - it may lead to inaccessible applications due to IDREF collisions.
Closed by #1408 |
🚀 Feature Proposal
I'd like to have stable generated IDs instead of completely different at each execution.
Motivation
As a developer I want to control these IDs and be able to use snapshots in automation to check their values. At the moment I have to mock the IDs because the ones generated by
uuid
are changing at every execution.The text was updated successfully, but these errors were encountered: