Skip to content

Conversation

@jonniebigodes
Copy link
Contributor

@jonniebigodes jonniebigodes commented Oct 7, 2025

Closes #32636

What I did

With this pull request, the features API page was updated to include the missing experimentalTestSyntax feature flag.

What was done:

  • Adjusted the documentation to render the options based on the selected framework conditionally
  • Included the missing feature flag
  • Added snippets

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make 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 PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Documentation
    • Added documentation and snippets for an experimental story test syntax, including guidance for attaching tests to stories.
    • Expanded configuration docs with renderer-specific feature-flag sections (React, Angular, generic) and examples for enabling experimental test syntax.
    • Documented Angular-specific behavior for filtering non-input controls and clarified which flags apply per renderer.

@jonniebigodes jonniebigodes added documentation ci:docs Run the CI jobs for documentation checks only. labels Oct 7, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 7, 2025

📝 Walkthrough

Walkthrough

Adds documentation describing a new experimental CSF "test" syntax and how to enable it via features.experimentalTestSyntax in Storybook main config; expands renderer-specific feature-flag docs (React, Angular, fallback) and adds an Angular-only flag entry.

Changes

Cohort / File(s) Summary of Changes
Docs snippet: experimentalTestSyntax
docs/_snippets/main-config-features-experimental-test-syntax.md
Adds example main config snippets (JS/TS, Next.js/React) that set features.experimentalTestSyntax: true. Documentation only.
Main-config features docs (renderer-specific)
docs/api/main-config/main-config-features.mdx
Expands feature-flag Type sections for React, Angular, and not-renderer fallback; adds angularFilterNonInputControls (Angular-only) and documents experimentalTestSyntax under React and mirrored in fallback with a snippet reference.
CSF Next: experimental test syntax
docs/api/csf/csf-next.mdx
Adds a new section describing the experimental <Story>.test API, code example of attaching tests to a story, and notes that it requires features.experimentalTestSyntax. Documentation only.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer
  participant StoryAPI as Story (CSF)
  participant TestHook as Test block
  participant Runner as Test runner

  Dev->>StoryAPI: define story
  Dev->>StoryAPI: call .test(fn)  %% configure test on story
  StoryAPI->>TestHook: store test function
  Runner->>StoryAPI: request tests for story
  StoryAPI->>TestHook: invoke test function
  TestHook->>Runner: return test results
  note over Dev,Runner #DFF2E6: Requires features.experimentalTestSyntax = true
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs_main_config_features_add_experimentaltestsyntax

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Oct 7, 2025

View your CI Pipeline Execution ↗ for commit bef844b

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 46s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-07 18:47:36 UTC

jonniebigodes and others added 2 commits October 7, 2025 18:33
- Remove irrelevant CSF 3 versions of snippet
- Add `<Story>.test` section to CSF Next reference
- Link to that section in `main-config-features` API reference
Copy link
Contributor

@kylegach kylegach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for handling this!

I pushed some updates, and now it's good to go.

@jonniebigodes jonniebigodes merged commit 331177b into next Oct 7, 2025
11 checks passed
@jonniebigodes jonniebigodes deleted the docs_main_config_features_add_experimentaltestsyntax branch October 7, 2025 18:27
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03ecabb and bef844b.

📒 Files selected for processing (3)
  • docs/_snippets/main-config-features-experimental-test-syntax.md (1 hunks)
  • docs/api/csf/csf-next.mdx (1 hunks)
  • docs/api/main-config/main-config-features.mdx (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Core Unit Tests, windows-latest

Comment on lines +237 to +245
// 👇 .test method: Attach tests to a story
// The test function can run the same code as the play function
PrimaryDisabled.test('should be disabled', async ({ canvas, userEvent, args }) => {
const button = await canvas.findByRole('button');
await userEvent(button).click();

await expect(button).toBeDisabled();
await expect(args.onClick).not.toHaveBeenCalled();
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix userEvent usage in <Story>.test example

Inside test/play functions Storybook passes userEvent as the preconfigured Testing Library instance, so you call its methods directly (await userEvent.click(button);). Calling it as a function (userEvent(button).click()) will throw because userEvent isn’t callable. Please update the snippet accordingly.

-PrimaryDisabled.test('should be disabled', async ({ canvas, userEvent, args }) => {
+PrimaryDisabled.test('should be disabled', async ({ canvas, userEvent, args }) => {
   const button = await canvas.findByRole('button');
-  await userEvent(button).click();
+  await userEvent.click(button);
 
   await expect(button).toBeDisabled();
   await expect(args.onClick).not.toHaveBeenCalled();
 });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 👇 .test method: Attach tests to a story
// The test function can run the same code as the play function
PrimaryDisabled.test('should be disabled', async ({ canvas, userEvent, args }) => {
const button = await canvas.findByRole('button');
await userEvent(button).click();
await expect(button).toBeDisabled();
await expect(args.onClick).not.toHaveBeenCalled();
});
// 👇 .test method: Attach tests to a story
// The test function can run the same code as the play function
PrimaryDisabled.test('should be disabled', async ({ canvas, userEvent, args }) => {
const button = await canvas.findByRole('button');
await userEvent.click(button);
await expect(button).toBeDisabled();
await expect(args.onClick).not.toHaveBeenCalled();
});
🤖 Prompt for AI Agents
In docs/api/csf/csf-next.mdx around lines 237 to 245, the example uses userEvent
as a callable (userEvent(button).click()) which is incorrect because Storybook
passes a preconfigured Testing Library userEvent instance; change the call to
use its method directly (await userEvent.click(button)) so the test invokes
userEvent.click with the target element.

@github-actions github-actions bot mentioned this pull request Oct 8, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:docs Run the CI jobs for documentation checks only. documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Documentation]: SB10 - Missing documentation on how to enable test syntax

3 participants