Skip to content

Conversation

@valentinpalkovic
Copy link
Contributor

@valentinpalkovic valentinpalkovic commented Dec 7, 2025

Closes #

What I did

When AddonVitestPostinstallError is thrown with sub-errors, telemetry sends separate events for the parent and each sub-error, improving error tracking and debugging.

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 publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Bug Fixes

    • Clearer, more specific error reporting during Vitest addon setup with structured failure messages and improved telemetry for multi-part failures.
    • Fixes to when Playwright-related failures are surfaced so only relevant errors are reported.
  • Chores

    • Internal error handling reworked for consistent aggregation and reporting.
    • Dev startup now respects dependency installation outcome rather than global error state.

✏️ Tip: You can customize this high-level summary in your review settings.

@valentinpalkovic valentinpalkovic force-pushed the valentin/addon-vitest-detailed-errors branch from ef46010 to b6eb30d Compare December 7, 2025 13:41
@nx-cloud
Copy link

nx-cloud bot commented Dec 8, 2025

View your CI Pipeline Execution ↗ for commit 578b5e5

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ✅ Succeeded 3m 52s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-09 08:30:36 UTC

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

📝 Walkthrough

Walkthrough

Refactors Vitest postinstall to collect and emit structured StorybookError instances (with subErrors) instead of strings, adds new Vitest-specific error classes, updates telemetry to accept/emit parent and sub-error events, and changes a dev-start condition to rely on dependencyInstallationResult.status.

Changes

Cohort / File(s) Summary
Vitest postinstall
code/addons/vitest/src/postinstall.ts
Switch error collection from string[] to StorybookError[]; replace string messages with specific AddonVitestPostinstall*Error instances; stop propagating Playwright return errors and accumulate new error objects across branches.
Core error model & new errors
code/core/src/storybook-error.ts, code/core/src/server-errors.ts
Add subErrors: StorybookError[] to StorybookError; introduce AddonVitestPostinstallFailedAddonA11yError, AddonVitestPostinstallExistingSetupFileError, AddonVitestPostinstallWorkspaceUpdateError, AddonVitestPostinstallConfigUpdateError; change AddonVitestPostinstallError to accept errors: StorybookError[] and populate subErrors.
Telemetry handling
code/core/src/core-server/withTelemetry.ts
Extend sendTelemetryError signature with optional parent?: StorybookError; include parent fullErrorCode in payload when provided; recursively emit telemetry for each subErrors entry using the original error as parent.
Dev start decision
code/lib/create-storybook/src/initiate.ts
Replace global error-collector check with dependencyInstallationResult.status === 'success' for shouldRunDev decision.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review propagation and construction of StorybookError instances in postinstall.ts to ensure contextual data (filePath/error) is correct.
  • Validate sendTelemetryError recursion to avoid duplicate or infinite telemetry emission and confirm parent linking semantics.
  • Confirm AddonVitestPostinstallError subErrors wiring and exports in server-errors.ts match downstream consumers.
  • Verify dependencyInstallationResult.status values and shouldRunDev logic in initiate.ts across possible return cases.

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings

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

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

🧹 Nitpick comments (1)
code/core/src/core-server/withTelemetry.ts (1)

138-147: Consider adding depth protection for deeply nested sub-errors.

While the current implementation correctly handles sub-errors recursively, there's no protection against deeply nested or potentially circular sub-error structures. Consider adding a maximum depth parameter to prevent stack overflow in edge cases.

 export async function sendTelemetryError(
   _error: unknown,
   eventType: EventType,
   options: TelemetryOptions,
   blocking = true,
-  parent?: StorybookError
+  parent?: StorybookError,
+  depth = 0
 ) {
   // ... existing code ...
 
       // If this is a StorybookError with sub-errors, send telemetry for each sub-error separately
-      if (error instanceof StorybookError && error.subErrors.length > 0) {
+      if (error instanceof StorybookError && error.subErrors.length > 0 && depth < 3) {
         for (const subError of error.subErrors) {
           if (subError instanceof StorybookError) {
-            await sendTelemetryError(subError, eventType, options, blocking, error);
+            await sendTelemetryError(subError, eventType, options, blocking, error, depth + 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 9548e92 and fa3ad72.

📒 Files selected for processing (5)
  • code/addons/vitest/src/postinstall.ts (8 hunks)
  • code/core/src/core-server/withTelemetry.ts (2 hunks)
  • code/core/src/server-errors.ts (1 hunks)
  • code/core/src/storybook-error.ts (1 hunks)
  • code/lib/create-storybook/src/initiate.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use ESLint and Prettier configurations that are enforced in the codebase

Files:

  • code/core/src/core-server/withTelemetry.ts
  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
  • code/lib/create-storybook/src/initiate.ts
  • code/core/src/storybook-error.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Enable TypeScript strict mode

Files:

  • code/core/src/core-server/withTelemetry.ts
  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
  • code/lib/create-storybook/src/initiate.ts
  • code/core/src/storybook-error.ts
code/**/*.{ts,tsx,js,jsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

code/**/*.{ts,tsx,js,jsx,mjs}: Use server-side logger from 'storybook/internal/node-logger' for Node.js code
Use client-side logger from 'storybook/internal/client-logger' for browser code
Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size

Files:

  • code/core/src/core-server/withTelemetry.ts
  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
  • code/lib/create-storybook/src/initiate.ts
  • code/core/src/storybook-error.ts
code/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Export functions that need to be tested from their modules

Files:

  • code/core/src/core-server/withTelemetry.ts
  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
  • code/lib/create-storybook/src/initiate.ts
  • code/core/src/storybook-error.ts
code/**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

code/**/*.{js,jsx,json,html,ts,tsx,mjs}: Run Prettier with --write flag to format code before committing
Run ESLint with yarn lint:js:cmd to check for linting issues and fix errors before committing

Files:

  • code/core/src/core-server/withTelemetry.ts
  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
  • code/lib/create-storybook/src/initiate.ts
  • code/core/src/storybook-error.ts
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Document complex mock behaviors in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid mocking only a subset of required dependencies in Vitest tests
📚 Learning: 2025-11-24T17:49:59.279Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid mocking only a subset of required dependencies in Vitest tests

Applied to files:

  • code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-24T17:49:31.838Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-24T17:49:31.838Z
Learning: Applies to code/vitest.workspace.ts : Vitest configuration is centralized in `code/vitest.workspace.ts` for workspace setup

Applied to files:

  • code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-24T17:49:59.279Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid inline mock implementations within test cases in Vitest tests

Applied to files:

  • code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-28T14:50:24.889Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T14:50:24.889Z
Learning: Applies to code/**/*.{ts,tsx,js,jsx,mjs} : Use server-side logger from 'storybook/internal/node-logger' for Node.js code

Applied to files:

  • code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-28T14:50:24.889Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T14:50:24.889Z
Learning: Follow existing patterns and conventions in the Storybook codebase

Applied to files:

  • code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-05T09:38:47.712Z
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/Select/Select.tsx:200-204
Timestamp: 2025-11-05T09:38:47.712Z
Learning: Repo: storybookjs/storybook — Guidance: Until Storybook 11 is released, do not suggest using React.useId anywhere (e.g., in code/core/src/components/components/Select/Select.tsx) to maintain compatibility with React 17 runtimes. Prefer advising: accept a caller-provided props.id and, if needed, generate a client-only fallback id to minimize SSR hydration issues — but avoid useId. Resume prompting for useId after Storybook 11.

Applied to files:

  • code/addons/vitest/src/postinstall.ts
  • code/lib/create-storybook/src/initiate.ts
📚 Learning: 2025-09-17T07:31:04.432Z
Learnt from: ndelangen
Repo: storybookjs/storybook PR: 32484
File: code/core/package.json:326-326
Timestamp: 2025-09-17T07:31:04.432Z
Learning: In Storybook's core package, dependencies like `open` are bundled into the final distribution during the build process, so they should remain in devDependencies rather than being moved to dependencies. End users don't need these packages as separate runtime dependencies since they're included in the bundled code.

Applied to files:

  • code/lib/create-storybook/src/initiate.ts
📚 Learning: 2025-09-29T13:20:23.346Z
Learnt from: mrginglymus
Repo: storybookjs/storybook PR: 32556
File: code/core/package.json:309-313
Timestamp: 2025-09-29T13:20:23.346Z
Learning: The `fast-printf` dependency in Storybook's core package is bundled into the final distribution during the build process, so it should remain in devDependencies rather than being moved to dependencies, following the same pattern as other bundled dependencies like `open`.

Applied to files:

  • code/lib/create-storybook/src/initiate.ts
📚 Learning: 2025-09-24T09:39:39.233Z
Learnt from: ndelangen
Repo: storybookjs/storybook PR: 32507
File: code/core/src/manager/globals/globals-module-info.ts:25-33
Timestamp: 2025-09-24T09:39:39.233Z
Learning: In Storybook, storybook/actions/decorator is a preview-only entrypoint and should not be included in manager globals configuration. The duplicatedKeys array in code/core/src/manager/globals/globals-module-info.ts is specifically for manager-side externalization, not preview entrypoints.

Applied to files:

  • code/lib/create-storybook/src/initiate.ts
🧬 Code graph analysis (1)
code/addons/vitest/src/postinstall.ts (1)
code/core/src/server-errors.ts (4)
  • AddonVitestPostinstallExistingSetupFileError (483-497)
  • AddonVitestPostinstallWorkspaceUpdateError (499-513)
  • AddonVitestPostinstallConfigUpdateError (515-529)
  • AddonVitestPostinstallFailedAddonA11yError (471-481)
⏰ 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). (3)
  • GitHub Check: normal
  • GitHub Check: nx
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (14)
code/lib/create-storybook/src/initiate.ts (1)

116-125: LGTM! Clear success condition.

The refactor from checking ErrorCollector.getErrors().length === 0 to dependencyInstallationResult.status === 'success' is a good improvement. It makes the success condition explicit and self-documenting, directly tied to the installation result rather than relying on a global error collector state.

code/core/src/storybook-error.ts (2)

74-93: LGTM! Well-documented sub-errors property.

The subErrors property is properly typed as StorybookError[] with a sensible default of an empty array. The JSDoc documentation clearly explains the purpose and provides a helpful usage example.


101-114: LGTM! Clean constructor extension.

The constructor properly accepts an optional subErrors parameter and initializes the property with nullish coalescing (props.subErrors ?? []), ensuring consistent behavior.

code/core/src/server-errors.ts (3)

471-481: LGTM! New A11y error class.

The error class follows the established pattern with a unique code (6) and appropriate isHandledError: true flag. The data property correctly captures the underlying error for debugging purposes.


483-529: LGTM! Well-structured file/workspace/config error classes.

The three new error classes (AddonVitestPostinstallExistingSetupFileError, AddonVitestPostinstallWorkspaceUpdateError, AddonVitestPostinstallConfigUpdateError) are consistently structured with:

  • Unique error codes (7, 8, 9)
  • Appropriate isHandledError: true flags
  • Documentation links pointing to manual setup instructions
  • Clear, actionable error messages

531-542: LGTM! Proper integration of subErrors.

The AddonVitestPostinstallError now accepts StorybookError[] instead of string[] and properly passes them via the subErrors constructor parameter. This enables the telemetry system to handle each sub-error individually.

code/core/src/core-server/withTelemetry.ts (2)

89-95: LGTM! Clean signature extension.

The optional parent?: StorybookError parameter is a clean addition that enables hierarchical error tracking without breaking existing callers.


129-131: LGTM! Parent context propagation.

Using spread with conditional inclusion (...(parent ? { parent: parent.fullErrorCode } : {})) is an idiomatic way to optionally include the parent error code in telemetry data.

code/addons/vitest/src/postinstall.ts (6)

40-40: LGTM! Properly typed error collection.

The errors array is now correctly typed as StorybookError[], enabling type-safe error aggregation throughout the postinstall flow.


162-171: LGTM! Structured error for existing setup file.

The error handling correctly uses the new AddonVitestPostinstallExistingSetupFileError with the file path, providing better telemetry context than a plain string.


262-265: LGTM! Structured error for workspace update failure.

Properly uses AddonVitestPostinstallWorkspaceUpdateError with the workspace file path for granular error tracking.


309-309: LGTM! Structured error for config update failure.

Correctly uses AddonVitestPostinstallConfigUpdateError with the config file path.


364-371: LGTM! Structured error for A11y addon failure.

The error handling captures the underlying exception in AddonVitestPostinstallFailedAddonA11yError, enabling better debugging through the data.error property.


29-29: Relative import is necessary — StorybookError is not exported via storybook/internal/* paths.

The StorybookError type cannot be imported from storybook/internal/server-errors because it is not re-exported from that path. The base StorybookError class is internal and only exported from code/core/src/storybook-error.ts. The relative import (../../../core/src/storybook-error) is the only valid approach, consistent with how StorybookError is imported throughout the codebase in other files like server-errors.ts, preview-errors.ts, and manager-errors.ts.

Comment on lines +146 to 148
await addonVitestService.installPlaywright({
yes: options.yes,
});
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 | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

find . -name "AddonVitestService.ts" -o -name "*AddonVitest*" | head -20

Repository: storybookjs/storybook

Length of output: 205


🏁 Script executed:

cd code && find . -path "*vitest*" -name "*.ts" -type f | head -20

Repository: storybookjs/storybook

Length of output: 814


🏁 Script executed:

cat -n code/core/src/cli/AddonVitestService.ts | head -100

Repository: storybookjs/storybook

Length of output: 4307


🏁 Script executed:

wc -l code/core/src/cli/AddonVitestService.ts

Repository: storybookjs/storybook

Length of output: 108


🏁 Script executed:

rg -n 'installPlaywright' code/core/src/cli/AddonVitestService.ts -A 30

Repository: storybookjs/storybook

Length of output: 1509


🏁 Script executed:

cat -n code/addons/vitest/src/postinstall.ts | head -160

Repository: storybookjs/storybook

Length of output: 7263


🏁 Script executed:

rg -n 'installPlaywright' code/core/src/cli/AddonVitestService.ts -A 50 | head -80

Repository: storybookjs/storybook

Length of output: 2291


🏁 Script executed:

rg -n 'installPlaywright' code/core/src/cli/AddonVitestService.ts -A 70 | tail -40

Repository: storybookjs/storybook

Length of output: 1379


🏁 Script executed:

sed -n '166,190p' code/core/src/cli/AddonVitestService.ts

Repository: storybookjs/storybook

Length of output: 710


🏁 Script executed:

sed -n '39,160p' code/addons/vitest/src/postinstall.ts | cat -n

Repository: storybookjs/storybook

Length of output: 5533


Handle Playwright installation failures by checking the return value.

The call to addonVitestService.installPlaywright() ignores the returned { errors, result } object. If installation fails (result='failed'), execution continues silently without notifying the user. Capture the return value and either throw an error or log a warning when result === 'failed' to maintain consistency with the error handling pattern used elsewhere in this function (e.g., lines 56-61 for compatibility checks).

🤖 Prompt for AI Agents
In code/addons/vitest/src/postinstall.ts around lines 146 to 148, the call to
addonVitestService.installPlaywright(...) currently ignores the returned {
errors, result } object; capture the return value, check if result === 'failed',
and handle it like the compatibility checks earlier (lines ~56-61) by either
throwing an Error (including the errors payload or a descriptive message) or
logging a warning and exiting—ensure you pass through options.yes as before and
include clear context in the error/warning so installation failures do not
continue silently.

@storybook-app-bot
Copy link

storybook-app-bot bot commented Dec 8, 2025

Package Benchmarks

Commit: 578b5e5, ran on 9 December 2025 at 08:01:49 UTC

The following packages have significant changes to their size or dependencies:

storybook

Before After Difference
Dependency count 39 39 0
Self size 20.52 MB 20.53 MB 🚨 +12 KB 🚨
Dependency size 16.41 MB 16.41 MB 0 B
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 173 173 0
Self size 774 KB 774 KB 0 B
Dependency size 67.60 MB 67.61 MB 🚨 +12 KB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 166 166 0
Self size 30 KB 30 KB 0 B
Dependency size 66.17 MB 66.18 MB 🚨 +12 KB 🚨
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 40 40 0
Self size 1000 KB 1000 KB 🎉 -73 B 🎉
Dependency size 36.93 MB 36.94 MB 🚨 +12 KB 🚨
Bundle Size Analyzer node node

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: 0

♻️ Duplicate comments (1)
code/addons/vitest/src/postinstall.ts (1)

146-148: Handle Playwright installation failures by checking the return value.

The call to addonVitestService.installPlaywright() ignores the returned value. If installation fails, execution continues silently without notifying the user. This is inconsistent with the error handling pattern used elsewhere (e.g., lines 69-99 for compatibility checks).

Capture the return value and handle failures appropriately:

-    await addonVitestService.installPlaywright({
+    const { errors: playwrightErrors, result: playwrightResult } = await addonVitestService.installPlaywright({
       yes: options.yes,
     });
+    if (playwrightResult === 'failed') {
+      logger.error('Playwright installation failed');
+      if (playwrightErrors && playwrightErrors.length > 0) {
+        playwrightErrors.forEach(err => logger.error(err));
+      }
+      // Consider whether to throw or push to errors array based on desired behavior
+    }
🧹 Nitpick comments (1)
code/core/src/server-errors.ts (1)

473-483: Include error details in the message for better debuggability.

The captured error is not included in the message string, which could make troubleshooting difficult. Consider following the pattern used in GoogleFontsLoadingError (line 330) by conditionally appending the error message.

Apply this diff to include error details:

 export class AddonVitestPostinstallFailedAddonA11yError extends StorybookError {
   constructor(public data: { error: unknown | Error }) {
     super({
       name: 'AddonVitestPostinstallFailedAddonA11yError',
-      message: "The @storybook/addon-a11y couldn't be set up for the Vitest addon",
+      message: dedent`
+        The @storybook/addon-a11y couldn't be set up for the Vitest addon.
+        
+        ${data.error instanceof Error ? data.error.message : ''}`,
       category: Category.CLI_INIT,
       isHandledError: true,
       code: 6,
     });
   }
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa3ad72 and 578b5e5.

📒 Files selected for processing (2)
  • code/addons/vitest/src/postinstall.ts (7 hunks)
  • code/core/src/server-errors.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use ESLint and Prettier configurations that are enforced in the codebase

Files:

  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Enable TypeScript strict mode

Files:

  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
code/**/*.{ts,tsx,js,jsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

code/**/*.{ts,tsx,js,jsx,mjs}: Use server-side logger from 'storybook/internal/node-logger' for Node.js code
Use client-side logger from 'storybook/internal/client-logger' for browser code
Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size

Files:

  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
code/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Export functions that need to be tested from their modules

Files:

  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
code/**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

code/**/*.{js,jsx,json,html,ts,tsx,mjs}: Run Prettier with --write flag to format code before committing
Run ESLint with yarn lint:js:cmd to check for linting issues and fix errors before committing

Files:

  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid mocking only a subset of required dependencies in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Document complex mock behaviors in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid inline mock implementations within test cases in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Group related mocks together in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Implement mock behaviors in `beforeEach` blocks in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Mock all required properties and methods that the test subject uses in Vitest tests
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid mock implementations outside of `beforeEach` blocks in Vitest tests
📚 Learning: 2025-11-28T14:50:24.889Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T14:50:24.889Z
Learning: Applies to code/**/*.{ts,tsx,js,jsx,mjs} : Use server-side logger from 'storybook/internal/node-logger' for Node.js code

Applied to files:

  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-28T14:50:24.889Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T14:50:24.889Z
Learning: Applies to code/**/*.{ts,tsx,js,jsx,mjs} : Use client-side logger from 'storybook/internal/client-logger' for browser code

Applied to files:

  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-28T14:50:24.889Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T14:50:24.889Z
Learning: Follow existing patterns and conventions in the Storybook codebase

Applied to files:

  • code/core/src/server-errors.ts
📚 Learning: 2025-11-05T09:38:47.712Z
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/Select/Select.tsx:200-204
Timestamp: 2025-11-05T09:38:47.712Z
Learning: Repo: storybookjs/storybook — Guidance: Until Storybook 11 is released, do not suggest using React.useId anywhere (e.g., in code/core/src/components/components/Select/Select.tsx) to maintain compatibility with React 17 runtimes. Prefer advising: accept a caller-provided props.id and, if needed, generate a client-only fallback id to minimize SSR hydration issues — but avoid useId. Resume prompting for useId after Storybook 11.

Applied to files:

  • code/core/src/server-errors.ts
  • code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-24T17:49:59.279Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-11-24T17:49:59.279Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid mocking only a subset of required dependencies in Vitest tests

Applied to files:

  • code/addons/vitest/src/postinstall.ts
📚 Learning: 2025-11-24T17:49:31.838Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-24T17:49:31.838Z
Learning: Applies to code/vitest.workspace.ts : Vitest configuration is centralized in `code/vitest.workspace.ts` for workspace setup

Applied to files:

  • code/addons/vitest/src/postinstall.ts
⏰ 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). (3)
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest
  • GitHub Check: nx
🔇 Additional comments (11)
code/core/src/server-errors.ts (5)

8-8: LGTM!

The re-export enables external consumers to access StorybookError through the server-errors module, supporting the new structured error handling.


485-499: LGTM!

The error class properly captures the file path context and provides clear guidance with documentation links.


501-515: LGTM!

The error class properly captures the file path context and provides clear guidance with documentation links.


517-531: LGTM!

The error class properly captures the file path context and provides clear guidance with documentation links.


533-544: LGTM!

The change from string-based to StorybookError[] errors enables structured error propagation through subErrors, which aligns with the PR's telemetry improvements.

code/addons/vitest/src/postinstall.ts (6)

14-22: LGTM!

The imports properly support the migration from string-based to structured error handling with typed error classes.


40-40: LGTM!

The type change correctly reflects the migration from string-based to structured error instances.


171-171: LGTM!

The error instance is properly created with the required filePath parameter, replacing the previous string-based approach.


262-264: LGTM!

The error instance is properly created with the required filePath parameter, replacing the previous string-based approach.


309-309: LGTM!

The error instance is properly created with the required filePath parameter, replacing the previous string-based approach.


370-370: LGTM!

The error instance is properly created with the required error parameter, replacing the previous string-based approach.

@valentinpalkovic valentinpalkovic added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Dec 9, 2025
@valentinpalkovic valentinpalkovic merged commit 46708d8 into next Dec 9, 2025
72 of 73 checks passed
@valentinpalkovic valentinpalkovic deleted the valentin/addon-vitest-detailed-errors branch December 9, 2025 08:25
valentinpalkovic added a commit that referenced this pull request Dec 9, 2025
…iled-errors

Addon-Vitest: Isolate error reasons during postinstall
(cherry picked from commit 46708d8)
@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addon: vitest bug ci:normal patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch telemetry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants