-
-
Notifications
You must be signed in to change notification settings - Fork 53
Run Storybook build and smoke tests in CI #1526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kotAPI
wants to merge
5
commits into
main
Choose a base branch
from
kotapi/add-ci-for-storybook-build-and-smoke-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7553e76
ci: run storybook smoke tests
kotAPI 8803f37
Handle multiple buttons in Storybook smoke tests
kotAPI 85dce38
docs: explain Storybook smoke test runner
kotAPI 5193b40
fix: use storybook test-runner CLI
kotAPI 9a09a88
fix: load Storybook testing utilities lazily
kotAPI File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Storybook Build and Test | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
storybook: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
cache: 'npm' | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Install Playwright | ||
run: npx playwright install --with-deps chromium | ||
- name: Build Storybook | ||
run: npm run build-storybook | ||
- name: Storybook smoke tests | ||
run: npm run test-storybook |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Basic smoke tests for Storybook stories. | ||
* | ||
* This configuration runs in CI via the Storybook test runner. It renders each | ||
* story and performs a minimal interaction to surface runtime errors that unit | ||
* tests might miss. | ||
* | ||
* What it covers: | ||
* - Verifies that stories render without throwing. | ||
* - Clicks the first button (if present) to catch simple interaction bugs. | ||
* | ||
* What it doesn't cover: | ||
* - Visual regressions or accessibility checks. | ||
* - Complex workflows that require multiple interactions. | ||
* - Stories that depend on network requests or auth; those may require mocks | ||
* or can be excluded from CI if flaky. | ||
* | ||
* This smoke test is a lightweight safety net and does not replace dedicated | ||
* unit, integration, or visual testing. | ||
*/ | ||
// If a button exists, click the first one to ensure the interaction doesn't trigger | ||
// runtime errors. | ||
export const run = async ({ canvasElement }) => { | ||
// Import testing utilities inside the runner so that Storybook's jsdom | ||
// environment is available. Importing at the module level throws because the | ||
// package expects `location` to exist on the global object. | ||
const { within, userEvent } = await import('@storybook/testing-library'); | ||
|
||
const canvas = within(canvasElement); | ||
// Use queryAllByRole so the test runner doesn't throw when multiple buttons | ||
// are present. | ||
const [button] = canvas.queryAllByRole('button'); | ||
if (button) { | ||
await userEvent.click(button); | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use setup-node v4 and current LTS
Node 18 reached EOL in April 2025; move to Node 20 (or 22) and the latest action.
📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.7)
16-16: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🤖 Prompt for AI Agents