-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Open
Description
Describe the bug
The current addon-vitest postinstall/init script is too sensitive to existing files. If it detects an existing .storybook/vitest.setup.ts, the process aborts with an error rather than verifying the configuration and proceeding or skipping gracefully. This creates a friction point for users who are incrementally upgrading or who have manually scaffolded their testing environment.
Proposed Solution: "Smart Skip" Logic
Instead of aborting, the postinstall script should be refactored to be idempotent. It should validate the existing environment and only take action if pieces are missing.
Logic Workflow:
- Detect: Check for the existence of .storybook/vitest.setup.ts.
- Verify Config: Check if vitest.config.ts (or vite.config.ts) already includes:
- The storybookTest plugin from @storybook/experimental-addon-test.
- The reference to the setupFiles array pointing to .storybook/vitest.setup.ts.
- Evaluate:
- If fully configured: Log a success message (e.g., "Vitest for Storybook is already properly configured. Skipping setup.") and exit gracefully.
- If partially configured: Only apply the missing pieces (e.g., if the setup file exists but the config doesn't point to it, update the config).
Reproduction link
Reproduction steps
No response
System
-Additional context
No response
dosubot
Metadata
Metadata
Assignees
Type
Projects
Status
In Progress