Skip to content

Commit

Permalink
chore(storybook): hide warning and show TestOnly stories in local bui…
Browse files Browse the repository at this point in the history
…lds (#7424)

**Related Issue:** #7338

## Summary

Creates a `STORYBOOK_SNAPSHOT_LOCAL_BUILD` environment variable and
automatically sets it in the `docs:preview` npm script. When the
environment variable is truthy, the storybook build:

- Hides the warning banner
- Displays both TestOnly and NoTest stories
  • Loading branch information
benelan committed Aug 3, 2023
1 parent e2a9e0a commit 96a0da9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/calcite-components/.storybook/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export function storyFilters(): {
excludeStories: RegExp | string[];
} {
return {
excludeStories: process.env.STORYBOOK_SCREENSHOT_TEST_BUILD ? /.*_NoTest$/ : /.*_TestOnly$/,
excludeStories: process.env.STORYBOOK_SCREENSHOT_TEST_BUILD
? /.*_NoTest$/
: process.env.STORYBOOK_SCREENSHOT_LOCAL_BUILD
? []
: /.*_TestOnly$/,
};
}
2 changes: 1 addition & 1 deletion packages/calcite-components/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {
}
`,
managerHead: (head: string): string => {
if (process.env.STORYBOOK_SCREENSHOT_TEST_BUILD) {
if (process.env.STORYBOOK_SCREENSHOT_TEST_BUILD || process.env.STORYBOOK_SCREENSHOT_LOCAL_BUILD) {
return head;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/calcite-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"clean": "npm run util:clean-js-files && rimraf node_modules dist www hydrate docs .turbo src/components.d.ts",
"deps:update": "updtr --exclude chalk cheerio typescript @types/jest jest jest-cli ts-jest puppeteer @whitespace/storybook-addon-html && npm audit fix",
"docs": "build-storybook",
"docs:preview": "npm run util:build-docs && start-storybook",
"docs:preview": "npm run util:build-docs && STORYBOOK_SCREENSHOT_LOCAL_BUILD=true start-storybook",
"lint": "concurrently npm:lint:*",
"lint:html": "prettier --write \"**/*.html\" >/dev/null",
"lint:json": "prettier --write \"**/*.json\" >/dev/null",
Expand Down

0 comments on commit 96a0da9

Please sign in to comment.