-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Describe the bug
I'm using storybook/vitest-addon, I'm setting up the vitest.config.ts and vitest.setup.ts, and when I open storybook, I'm able to run all the tests for the first time, but when I run it again, I get this error:
Error
Failed to run tests
[birpc] rpc is closed, cannot call "onCancel"
Error:
at _call (file:///Users/aziz/repos/PepinoTech/ExpensyaWebWithUnitTests/Expensya.Web/node_modules/@vitest/browser/dist/index.js:2694:13)
at Proxy.sendEvent (file:///Users/aziz/repos/PepinoTech/ExpensyaWebWithUnitTests/Expensya.Web/node_modules/@vitest/browser/dist/index.js:2770:38)
at file:///Users/aziz/repos/PepinoTech/ExpensyaWebWithUnitTests/Expensya.Web/node_modules/@vitest/browser/dist/index.js:3151:35
at file:///Users/aziz/repos/PepinoTech/ExpensyaWebWithUnitTests/Expensya.Web/node_modules/vitest/dist/chunks/cli-api.D48wY175.js:11695:73
at Array.map ()
at Vitest.cancelCurrentRun (file:///Users/aziz/repos/PepinoTech/ExpensyaWebWithUnitTests/Expensya.Web/node_modules/vitest/dist/chunks/cli-api.D48wY175.js:11695:55)
at VitestManager.cancelCurrentRun (file:///Users/aziz/repos/PepinoTech/ExpensyaWebWithUnitTests/Expensya.Web/node_modules/@storybook/addon-vitest/dist/node/vitest.mjs:18:3821)
at VitestManager.runTests (file:///Users/aziz/repos/PepinoTech/ExpensyaWebWithUnitTests/Expensya.Web/node_modules/@storybook/addon-vitest/dist/node/vitest.mjs:18:3127)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at callback (file:///Users/aziz/repos/PepinoTech/ExpensyaWebWithUnitTests/Expensya.Web/node_modules/@storybook/addon-vitest/dist/node/vitest.mjs:19:1331)
at file:///Users/aziz/repos/PepinoTech/ExpensyaWebWithUnitTests/Expensya.Web/node_modules/@storybook/addon-vitest/dist/node/vitest.mjs:19:2119
at Object.runWithState (/Users/aziz/repos/PepinoTech/ExpensyaWebWithUnitTests/Expensya.Web/node_modules/storybook/dist/core-server/index.cjs:44691:11)
at _TestManager.runTestsWithState (file:///Users/aziz/repos/PepinoTech/ExpensyaWebWithUnitTests/Expensya.Web/node_modules/@storybook/addon-vitest/dist/node/vitest.mjs:19:2064)
at _TestManager.handleTriggerRunEvent (file:///Users/aziz/repos/PepinoTech/ExpensyaWebWithUnitTests/Expensya.Web/node_modules/@storybook/addon-vitest/dist/node/vitest.mjs:19:1162)
Reproduction
vitest.config.ts:
import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
import { playwright } from "@vitest/browser-playwright";
import path from "node:path";
import { defineConfig } from "vite";
import { defineProject, mergeConfig } from "vitest/config";
import viteConfig from "./.storybook/vite.config";
export default defineConfig({
test: {
projects: [
defineProject(
mergeConfig(
viteConfig,
{
plugins: [
storybookTest({
// The location of your Storybook config, main.js|ts
configDir: path.join(__dirname, ".storybook"),
// This should match your package.json script to run Storybook
// The --no-open flag will skip the automatic opening of a browser
storybookScript: "npm run storybook -- --no-open",
}),
],
test: {
name: "storybook",
// Enable browser mode
browser: {
enabled: true,
provider: playwright({}),
headless: true,
instances: [{ browser: "chromium" }],
},
setupFiles: ["./.storybook/vitest.setup.ts"],
}
}
)
),
],
}
});vitest.setup.ts
import { setProjectAnnotations } from "@storybook/react-vite";
import * as previewAnnotations from "./preview";
setProjectAnnotations([previewAnnotations]);System Info
System:
OS: macOS 26.1
CPU: (14) arm64 Apple M4 Pro
Memory: 3.35 GB / 48.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.19.5 - ~/.nvm/versions/node/v20.19.5/bin/node
npm: 10.8.2 - ~/.nvm/versions/node/v20.19.5/bin/npm
Browsers:
Chrome: 142.0.7444.176
Edge: 142.0.3595.80
Safari: 26.1
npmPackages:
@vitest/browser-playwright: 4.0.9 => 4.0.9
@vitest/coverage-v8: 4.0.9 => 4.0.9
playwright: 1.56.1 => 1.56.1
vite: 6.4.1 => 6.4.1
vitest: 4.0.9 => 4.0.9 Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.