Skip to content

Commit 165305e

Browse files
authored
Disable Chromatic snapshots globally (#2130)
## 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
1 parent 6f2813c commit 165305e

File tree

5 files changed

+227
-223
lines changed

5 files changed

+227
-223
lines changed

.changeset/dull-cars-reply.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@khanacademy/perseus": patch
3+
---
4+
5+
Change interactive-graph visual regression stories to Storybook's CSF v3

.changeset/quiet-files-marry.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/workflows/storybook.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
token: ${{ secrets.GITHUB_TOKEN }}
4444
projectToken: ${{ secrets.CHROMATIC_APP_CODE }}
4545
autoAcceptChanges: "main"
46-
onlyStoryFiles: "**/*regression.stories.tsx"
46+
onlyStoryFiles: "**/*-regression.stories.tsx"
4747
# NOTE: We cannot enable `onlyChanged` because it is
4848
# incompatible with `onlyStoryFiles` which we use above.
4949
# onlyChanged: true # Enable TurboSnap!

.storybook/preview.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ const preview: Preview = {
4141
// These parameters apply to all stories, both inside and outside the fixture
4242
// framework.
4343
parameters: {
44+
// Disables Chromatic's snapshotting on a global level
45+
// We disable snapshotting globally because we have enabled
46+
// turbosnaps for `-regression.stories.tsx` files. If we have
47+
// snapshots enabled globally, we pay for turbosnaps even for
48+
// skipped stories/tests (which is all of them).
49+
// We then enable snapshots for `-regression.stories.tsx` files in
50+
// each of those files (unfortunately, this is how we have to do
51+
// it).
52+
chromatic: {disableSnapshot: true},
53+
4454
options: {
4555
storySort: {
4656
order: ["Perseus", "PerseusEditor", "Math-Input", "*"],

0 commit comments

Comments
 (0)