Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Add Vitest snapshost test example.
Problem
With no configuration, CSS does not appear in snapshots and is not subject for testing.
Also, in kuma-ui, since the hash is calculated using the style string, if the style changes, only the classnames will have a diff. I think this diff lacks information and is not enough convincing for developer to approve this change.
Solution
For this reason, I have written an implementation of a custom serializer in a format very similar to @emotion/jest.
https://emotion.sh/docs/testing
As a result, the hash is assigned an index that does not depend on the description in the order of appearance, so no differences will appear in the value of the class itself. Also, since CSS is output at the beginning of the snapshot, it becomes possible to collectively verify changes in style with the component's snapshot.
Comment
The implementation of this serializer is not so strongly related to the implementation of kuma-ui itself, so I think it's not worth packaging, but I think it's no problem to have it as a reference implementation. What do you think?