CSF: Add Storybook test syntax (Storybook v9)#32391
Closed
yannbf wants to merge 159 commits into
Closed
Conversation
- Changed instances of `isCI` to `isCI()` in various files to ensure consistent function usage. - Updated related logic in `postinstall-logger.ts`, `postinstall.ts`, `withTelemetry.ts`, and others to reflect this change. - Enhanced test coverage for `isCI` behavior in `storybook-metadata.test.ts`.
- Replaced direct imports of `isCI` and `logger` from internal paths with imports from centralized utility modules. - This change enhances maintainability and consistency across the codebase.
Release: Preminor alpha 9.2.0-alpha.0
Telemetry: Send index stats on dev exit
This was referenced Sep 4, 2025
This reverts commit f793686.
Vitest: Fix focused test run in Storybook sidebar
…emods CSF: Enhance csf-factories codemods
Core: Add include/exclude toggle for each tag in tags filter UI
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #32244
What I did
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This pull request has been released as version
0.0.0-pr-32391-sha-41c83af5. Try it out in a new sandbox by runningnpx storybook@0.0.0-pr-32391-sha-41c83af5 sandboxor in an existing project withnpx storybook@0.0.0-pr-32391-sha-41c83af5 upgrade.More information
0.0.0-pr-32391-sha-41c83af5feature/test-syntax-in-csf41c83af51757011704)To request a new release of this pull request, mention the
@storybookjs/coreteam.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=32391Greptile Summary
Updated On: 2025-09-03 17:13:50 UTC
This PR introduces a comprehensive test syntax feature for Storybook's Component Story Format (CSF) that allows developers to define test functions directly on stories using a
.test()method. The changes implement a new hierarchical story/test relationship where tests become child entries of their parent stories.Key Changes:
Core Architecture:
StoryIndexEntrywith asubtypefield ('story' | 'test') to distinguish between regular stories and test entriesparentandparentNamefields for test entries to establish hierarchical relationshipsAPI_TestEntrytype alongside existingAPI_StoryEntryfor type safetyTest Syntax API:
.test(name, testFn)and.test(name, overrides, testFn)method callsStoryContextas play functions and can be async or syncUI Integration:
Indexing and Processing:
.test()method calls and extract test metadatatoTestId()function with colon separator (e.g.,storyId:testName)Type System Updates:
subtype: 'story'TestFunctiontype introduced parallel to existingPlayFunctionThe feature enables a new testing paradigm where component tests can be co-located with their stories, inheriting story configuration while providing test-specific overrides. This creates a more integrated testing experience within the Storybook ecosystem.
PR Description Notes: