Skip to content
This repository has been archived by the owner on May 15, 2022. It is now read-only.

Implement the @emotion/jest serializer for storyshots to include the style information #5

Closed
geisterfurz007 opened this issue May 5, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@geisterfurz007
Copy link
Owner

geisterfurz007 commented May 5, 2021

Why

Currently snapshots look like this:

  <button
    type="button"
    label="Button"
    class=".chakra-button .css-oqfhsh"
  >
    Button
  </button>

With chakra-button supposedly containing the default chakra styling and css-oqfhsh containing additional style information processed by emotion. Getting to know this additional style information is desirable since it allows for more subtle changes in colors to be detected that Chromatic doesn't seem to pick up.

How?

Following https://emotion.sh/docs/testing, this should be as easy as adding the @emotion/jest/serializer to the snapshotSerializer array, however in tests that didn't seem to suffice.

From my understanding the order of operations needs to be:

  1. Preact renders story to object
  2. Emotion serializer resolves the styles
  3. Preact object is rendered to HTML
  4. Emotion serializer replaces the styles

Step 2-4 should "just" function within the emotion serializer given that the correct snapshot serializer is used from the provided array, getting the story rendered to an object however has been proven to be a bigger issue in earlier attempts.

@geisterfurz007
Copy link
Owner Author

Closing before archive.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant