Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
fe7f9b8
Move vitest workspace config from code/ to repo root
kasperpeulen Mar 17, 2026
7396407
Fix NX cache inputs and restore DRY storybook:vitest scripts
kasperpeulen Mar 17, 2026
bb7153b
Fix CircleCI test jobs to run from repo root
kasperpeulen Mar 17, 2026
eed6a37
Upgrade vitest from 4.0.14 to 4.1.0
kasperpeulen Mar 17, 2026
6079fbd
Fix test-manager mock for vitest 4.1.0 compatibility
kasperpeulen Mar 17, 2026
05865b1
Address PR review feedback and fix addon-vitest type check
kasperpeulen Mar 17, 2026
ecd2996
Fix BrowserCommands augmentation by deduplicating vitest
kasperpeulen Mar 17, 2026
7bfea23
Remove test/test:watch/affected:test scripts from code/package.json
kasperpeulen Mar 17, 2026
a78e33b
Move storybook:vitest scripts from code/ to root package.json
kasperpeulen Mar 17, 2026
e9cc2d3
Remove unused scripts from code/package.json
kasperpeulen Mar 17, 2026
403a41d
Revert "Remove unused scripts from code/package.json"
kasperpeulen Mar 17, 2026
dd4d337
Note in AGENTS.md that the default branch is next
kasperpeulen Mar 17, 2026
7ffabb5
Fix tests that relied on process.cwd() being code/
kasperpeulen Mar 17, 2026
0134642
Revert unrelated publish.yml change and remove unnecessary configDir
kasperpeulen Mar 17, 2026
f31885c
Update yarn.lock
kasperpeulen Mar 17, 2026
8b78c8b
Merge branch 'next' into kasper/vitest-root-migration
kasperpeulen Mar 17, 2026
8a7137c
Restore publish.yml to match next
kasperpeulen Mar 17, 2026
8b2044a
Remove reactDocgenTypescript test (covered elsewhere)
kasperpeulen Mar 17, 2026
4e27527
Restore configDir in storybook vitest config (needed when running fro…
kasperpeulen Mar 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This file is the canonical instruction source for coding agents. Files like `CLA

## Repository Overview

Storybook is a large TypeScript monorepo. The git root is the repo root, the main code lives in `code/`, and build tooling lives in `scripts/`.
Storybook is a large TypeScript monorepo. The git root is the repo root, the main code lives in `code/`, and build tooling lives in `scripts/`. The default branch is `next`.

- **Base branch**: `next` (all PRs should target `next`, not `main`)
- **Node.js**: `22.21.1` (see `.nvmrc`)
Expand Down Expand Up @@ -112,9 +112,9 @@ yarn nx run-many -t check
```bash
cd code && yarn storybook:ui
cd code && yarn storybook:ui:build
cd code && yarn test
cd code && yarn test:watch
cd code && yarn storybook:vitest
yarn test
yarn test:watch
yarn storybook:vitest
```

### Common task scenarios
Expand All @@ -126,8 +126,8 @@ cd code && yarn storybook:vitest
| Check TypeScript errors quickly | `yarn nx run-many -t check` |
| Start the internal Storybook UI | `cd code && yarn storybook:ui` |
| Build the internal Storybook UI | `cd code && yarn storybook:ui:build` |
| Run unit tests | `cd code && yarn test` |
| Run Storybook Vitest tests | `cd code && yarn storybook:vitest` |
| Run unit tests | `yarn test` |
| Run Storybook Vitest tests | `yarn storybook:vitest` |
| Generate a sandbox | `yarn task sandbox --template react-vite/default-ts --start-from auto` |
| Run sandbox E2E tests | `yarn task e2e-tests-dev --template react-vite/default-ts --start-from auto` |
| Run sandbox test-runner tests | `yarn task test-runner-dev --template react-vite/default-ts --start-from auto` |
Expand Down Expand Up @@ -210,7 +210,7 @@ Common templates:

## Testing Expectations

- Use `cd code && yarn test` for unit tests
- Use `yarn test` for unit tests
- Use Storybook UI or Chromatic for visual validation
- Use `yarn task e2e-tests --start-from auto` or `yarn task e2e-tests-dev --start-from auto` for E2E coverage
- Use `yarn task test-runner --start-from auto` or `yarn task test-runner-dev --start-from auto` for test-runner scenarios
Expand All @@ -219,9 +219,8 @@ Common templates:
Watch-mode commands:

```bash
cd code && yarn test:watch
yarn affected:test
cd code && yarn storybook:vitest
yarn test:watch
yarn storybook:vitest
```

When writing tests:
Expand Down
6 changes: 3 additions & 3 deletions code/addons/vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
"@types/micromatch": "^4.0.0",
"@types/node": "^22.19.1",
"@types/semver": "^7.7.1",
"@vitest/browser-playwright": "^4.0.14",
"@vitest/runner": "^4.0.14",
"@vitest/browser-playwright": "^4.1.0",
"@vitest/runner": "^4.1.0",
"empathic": "^2.0.0",
"es-toolkit": "^1.43.0",
"istanbul-lib-report": "^3.0.1",
Expand All @@ -102,7 +102,7 @@
"tree-kill": "^1.2.2",
"ts-dedent": "^2.2.0",
"typescript": "^5.9.3",
"vitest": "^4.0.14"
"vitest": "^4.1.0"
},
"peerDependencies": {
"@vitest/browser": "^3.0.0 || ^4.0.0",
Expand Down
3 changes: 1 addition & 2 deletions code/addons/vitest/src/node/test-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const vitest = vi.hoisted(() => ({

const mockCreateVitest = vi.fn();

vi.mock('vitest/node', async (importOriginal) => ({
...(await importOriginal()),
vi.mock('vitest/node', () => ({
createVitest: mockCreateVitest,
}));
Comment thread
kasperpeulen marked this conversation as resolved.

Expand Down
30 changes: 16 additions & 14 deletions code/lib/eslint-plugin/src/rules/no-uninstalled-addons.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { sep } from 'path';
import ruleTester from '../test-utils';
import rule from './no-uninstalled-addons';

const rootDir = process.cwd().split(sep).pop();

vi.mock('fs', () => ({
...vi.importActual('fs'),
readFileSync: () => `
Expand Down Expand Up @@ -177,7 +179,7 @@ ruleTester.run('no-uninstalled-addons', rule, {
type: AST_NODE_TYPES.Literal,
data: {
addonName: '@storybook/not-installed-addon',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
],
Expand All @@ -201,7 +203,7 @@ ruleTester.run('no-uninstalled-addons', rule, {
type: AST_NODE_TYPES.Literal,
data: {
addonName: '@storybook/not-installed-addon',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
],
Expand All @@ -224,7 +226,7 @@ ruleTester.run('no-uninstalled-addons', rule, {
type: AST_NODE_TYPES.Literal,
data: {
addonName: '@storybook/addon-esentials',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
],
Expand All @@ -245,7 +247,7 @@ ruleTester.run('no-uninstalled-addons', rule, {
type: AST_NODE_TYPES.Literal,
data: {
addonName: '@storybook/adon-essentials',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
],
Expand All @@ -268,15 +270,15 @@ ruleTester.run('no-uninstalled-addons', rule, {
type: AST_NODE_TYPES.Literal,
data: {
addonName: 'addon-withut-the-prefix',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
{
messageId: 'addonIsNotInstalled',
type: AST_NODE_TYPES.Literal,
data: {
addonName: '@storybook/addon-esentials',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
],
Expand All @@ -299,15 +301,15 @@ ruleTester.run('no-uninstalled-addons', rule, {
type: AST_NODE_TYPES.Literal,
data: {
addonName: 'addon-withut-the-prefix',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
{
messageId: 'addonIsNotInstalled',
type: AST_NODE_TYPES.Literal,
data: {
addonName: '@storybook/addon-esentials',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
],
Expand All @@ -330,15 +332,15 @@ ruleTester.run('no-uninstalled-addons', rule, {
type: AST_NODE_TYPES.Literal,
data: {
addonName: 'addon-withut-the-prefix',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
{
messageId: 'addonIsNotInstalled',
type: AST_NODE_TYPES.Literal,
data: {
addonName: '@storybook/addon-esentials',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
],
Expand All @@ -362,15 +364,15 @@ ruleTester.run('no-uninstalled-addons', rule, {
type: AST_NODE_TYPES.Literal,
data: {
addonName: 'addon-withut-the-prefix',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
{
messageId: 'addonIsNotInstalled',
type: AST_NODE_TYPES.Literal,
data: {
addonName: '@storybook/addon-esentials',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
],
Expand All @@ -392,15 +394,15 @@ ruleTester.run('no-uninstalled-addons', rule, {
type: AST_NODE_TYPES.Literal,
data: {
addonName: 'addon-withut-the-prefix',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
{
messageId: 'addonIsNotInstalled',
type: AST_NODE_TYPES.Literal,
data: {
addonName: '@storybook/addon-esentials',
packageJsonPath: `code${sep}`,
packageJsonPath: `${rootDir}${sep}`,
},
},
],
Expand Down
19 changes: 7 additions & 12 deletions code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
"url": "https://opencollective.com/storybook"
},
"scripts": {
"affected:test": "nx show projects --affected -t test | xargs -I # echo --project # | xargs yarn test:watch",
"await-serve-storybooks": "wait-on http://localhost:8001",
"build": "NODE_ENV=production yarn --cwd ../scripts build-package",
"changelog": "pr-log --sloppy --cherry-pick",
"changelog:next": "pr-log --sloppy --since-prerelease",
"check": "NODE_ENV=production yarn --cwd ../scripts check-package",
"ci-tests": "yarn task --task check --no-link --start-from=install && yarn lint && yarn test && cd ../scripts && yarn test",
"ci-tests": "yarn task --task check --no-link --start-from=install && yarn lint && cd .. && yarn test",
"danger": "danger",
"generate-sandboxes": "yarn --cwd ../scripts generate-sandboxes",
"github-release": "github-release-from-changelog",
Expand All @@ -37,11 +36,7 @@
"storybook:ui": "NODE_OPTIONS=\"--max_old_space_size=4096 --trace-deprecation\" core/dist/bin/dispatcher.js dev --port 6006 --config-dir ./.storybook",
"storybook:ui:build": "NODE_OPTIONS=\"--max_old_space_size=4096\" core/dist/bin/dispatcher.js build --config-dir ./.storybook --webpack-stats-json",
"storybook:ui:chromatic": "chromatic --storybook-build-dir storybook-static --exit-zero-on-changes --exit-once-uploaded",
"storybook:vitest": "yarn test:watch --project storybook-ui",
"storybook:vitest:inspect": "INSPECT=true yarn test --project storybook-ui",
"task": "yarn --cwd ../scripts task",
"test": "NODE_OPTIONS=--max_old_space_size=4096 vitest run",
"test:watch": "NODE_OPTIONS=--max_old_space_size=4096 vitest watch"
"task": "yarn --cwd ../scripts task"
},
"lint-staged": {
"*.{html,js,json,jsx,mjs,ts,tsx}": [
Expand Down Expand Up @@ -115,10 +110,10 @@
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react": "^4.3.2",
"@vitejs/plugin-vue": "^4.4.0",
"@vitest/browser": "^4.0.14",
"@vitest/browser-playwright": "^4.0.14",
"@vitest/coverage-istanbul": "^4.0.14",
"@vitest/coverage-v8": "^4.0.14",
"@vitest/browser": "^4.1.0",
"@vitest/browser-playwright": "^4.1.0",
"@vitest/coverage-istanbul": "^4.1.0",
"@vitest/coverage-v8": "^4.1.0",
"chromatic": "^13.3.4",
"create-storybook": "workspace:*",
"cross-env": "^7.0.3",
Expand Down Expand Up @@ -146,7 +141,7 @@
"uuid": "^11.1.0",
"vite": "^7.0.4",
"vite-plugin-inspect": "^11.0.0",
"vitest": "^4.0.14",
"vitest": "^4.1.0",
"wait-on": "^8.0.3"
},
"dependenciesMeta": {
Expand Down
4 changes: 2 additions & 2 deletions code/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"test": {
"dependsOn": [{ "projects": ["*"], "target": "compile" }],
"executor": "nx:run-commands",
"options": { "cwd": "{projectRoot}", "command": "yarn test" },
"options": { "command": "yarn test" },
"cache": true,
"inputs": ["default"],
"inputs": ["default", "{workspaceRoot}/vitest.config.ts"],
"configurations": { "production": {} }
},
"knip": {
Expand Down
Loading
Loading