Skip to content

Commit

Permalink
Disable Chromatic snapshots globally (#2130)
Browse files Browse the repository at this point in the history
## Summary:

This PR disables Chromatic snapshots globally (in `preview.tsx`) and then enables it in the one `-regression.stories.tsx` file.

Going forward, we can enable snapshots per-file.

We are making this change to address the fact that hte Perseus repo has been burning through our organization-wide Turbosnap budget because even skipped tests contribute to the Turbosnap count when snapshots are enabled (see the support thread that Juan had with Chromatic: https://khanacademy.slack.com/archives/CEA6W0F6F/p1737389339991279?thread_ts=1737389278.405609&cid=CEA6W0F6F). Specifically, in our Perseus repo we use `onlyStoryFiles`:

> OnlyStoryNames, OnlyStoryFiles work exactly like TurboSnap. The bypassed snapshots (skipping 366 tests) are counted and charged as TurboSnaps.

| Before | After |
| ------ | ----- |
| <img width="920" alt="original" src="https://github.com/user-attachments/assets/1a4db65c-dee6-4d15-9e20-743a3eae1394" /> | <img width="956" alt="after" src="https://github.com/user-attachments/assets/8bdb7edb-3726-4a20-9a8a-d003af5b33ec" /> | 



Issue: "none"

## Test plan:

Land the PR and then watch the build and make sure it doesn't write out that it skipped +300 tests.

Author: jeremywiebe

Reviewers: jeremywiebe, jandrade, #perseus, nishasy

Required Reviewers:

Approved By: jandrade

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x)

Pull Request URL: #2130
  • Loading branch information
jeremywiebe authored Jan 20, 2025
1 parent 6f2813c commit 165305e
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 223 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-cars-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Change interactive-graph visual regression stories to Storybook's CSF v3
2 changes: 2 additions & 0 deletions .changeset/quiet-files-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 1 addition & 1 deletion .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
projectToken: ${{ secrets.CHROMATIC_APP_CODE }}
autoAcceptChanges: "main"
onlyStoryFiles: "**/*regression.stories.tsx"
onlyStoryFiles: "**/*-regression.stories.tsx"
# NOTE: We cannot enable `onlyChanged` because it is
# incompatible with `onlyStoryFiles` which we use above.
# onlyChanged: true # Enable TurboSnap!
10 changes: 10 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ const preview: Preview = {
// These parameters apply to all stories, both inside and outside the fixture
// framework.
parameters: {
// Disables Chromatic's snapshotting on a global level
// We disable snapshotting globally because we have enabled
// turbosnaps for `-regression.stories.tsx` files. If we have
// snapshots enabled globally, we pay for turbosnaps even for
// skipped stories/tests (which is all of them).
// We then enable snapshots for `-regression.stories.tsx` files in
// each of those files (unfortunately, this is how we have to do
// it).
chromatic: {disableSnapshot: true},

options: {
storySort: {
order: ["Perseus", "PerseusEditor", "Math-Input", "*"],
Expand Down
Loading

0 comments on commit 165305e

Please sign in to comment.