feat(storybook): wire @storybook/test-runner for story smoke tests
Every story is now executed as a smoke test (mount + no console errors) via @storybook/test-runner. New script: pnpm test:stories runs build-storybook then test-storybook against the static build. Spec: §6.8 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,8 +6,11 @@
|
||||
"scripts": {
|
||||
"build": "echo 'Storybook build — use pnpm dev for development'",
|
||||
"build:storybook": "storybook build",
|
||||
"build-storybook": "storybook build",
|
||||
"dev": "storybook dev -p 6006",
|
||||
"lint": "eslint ."
|
||||
"lint": "eslint .",
|
||||
"test-storybook": "test-storybook --url http://localhost:6006",
|
||||
"test:stories": "concurrently -k -s first -n 'SB,TEST' -c 'magenta,blue' 'pnpm exec http-server storybook-static --port 6006 --silent' 'pnpm exec wait-on tcp:6006 && pnpm test-storybook'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@repo/core-ui": "workspace:*"
|
||||
@@ -18,11 +21,16 @@
|
||||
"@storybook/addon-essentials": "^8.6.0",
|
||||
"@storybook/react": "^8.6.0",
|
||||
"@storybook/react-vite": "^8.6.0",
|
||||
"@storybook/test-runner": "^0.19.1",
|
||||
"@tailwindcss/vite": "^4.1.0",
|
||||
"concurrently": "^9.0.0",
|
||||
"http-server": "^14.1.0",
|
||||
"playwright": "^1.52.0",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
"storybook": "^8.6.0",
|
||||
"tailwindcss": "^4.1.0",
|
||||
"vite": "^6.3.0"
|
||||
"vite": "^6.3.0",
|
||||
"wait-on": "^8.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
13
apps/storybook/test-runner.config.ts
Normal file
13
apps/storybook/test-runner.config.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { TestRunnerConfig } from "@storybook/test-runner";
|
||||
|
||||
const config: TestRunnerConfig = {
|
||||
async preVisit(page) {
|
||||
page.on("console", (msg) => {
|
||||
if (msg.type() === "error") {
|
||||
throw new Error(`Console error in story: ${msg.text()}`);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -6,6 +6,6 @@
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "*.ts", "*.tsx"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"lint": "turbo run lint",
|
||||
"test": "turbo run test",
|
||||
"test:e2e": "turbo run test:e2e",
|
||||
"test:stories": "turbo run test:stories",
|
||||
"typecheck": "turbo run typecheck",
|
||||
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
|
||||
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,md}\""
|
||||
|
||||
3125
pnpm-lock.yaml
generated
3125
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -51,6 +51,13 @@
|
||||
},
|
||||
"typecheck": {
|
||||
"dependsOn": ["^typecheck"]
|
||||
},
|
||||
"build-storybook": {
|
||||
"outputs": ["storybook-static/**"]
|
||||
},
|
||||
"test:stories": {
|
||||
"dependsOn": ["build-storybook"],
|
||||
"cache": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user