Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Upgrade to Storybook 8.3.0-beta.0, add Vitest to UI package #4802

Merged
merged 6 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion packages/ui/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const config: StorybookConfig = {
addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('storybook-dark-mode')
getAbsolutePath('storybook-dark-mode'),
getAbsolutePath('@storybook/experimental-addon-test')
],
framework: {
name: getAbsolutePath('@storybook/sveltekit'),
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const preview: Preview = {
backgrounds: { disable: true },
controls: {
matchers: {
color: /(background|color)$/i,
// matches "background" and "color" but not "solidBackground" as that is a boolean arg
color: /(?<!solid)(background|color)$/i,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this silents a console warning that the controls addon was logging in a story that uses solidBackground. The console warning was more noticeable in the Vitest tests because it would show up in the output.

date: /Date$/i
}
},
Expand Down
7 changes: 7 additions & 0 deletions packages/ui/.storybook/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { beforeAll } from 'vitest';
import { setProjectAnnotations } from '@storybook/sveltekit';
import * as projectAnnotations from './preview';

const project = setProjectAnnotations(projectAnnotations);

beforeAll(project.beforeAll);
25 changes: 16 additions & 9 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,44 @@
"prepublishOnly": "pnpm run package",
"prepare": "svelte-kit sync",
"storybook": "storybook dev --no-open -p 6006",
"storybook:build": "storybook build"
"storybook:build": "storybook build",
"test": "vitest run --mode development",
"test:watch": "vitest --watch --mode development",
"playwright:install": "playwright install --with-deps chromium"
},
"devDependencies": {
"@csstools/postcss-bundler": "^1.0.15",
"@storybook/addon-docs": "^8.2.7",
"@storybook/addon-essentials": "^8.2.7",
"@storybook/addon-links": "^8.2.7",
"@storybook/blocks": "^8.2.7",
"@storybook/svelte": "^8.2.7",
"@storybook/sveltekit": "^8.2.7",
"@storybook/addon-docs": "^8.3.0",
"@storybook/addon-essentials": "^8.3.0",
"@storybook/addon-links": "^8.3.0",
"@storybook/blocks": "^8.3.0",
"@storybook/experimental-addon-test": "^8.3.0",
"@storybook/svelte": "^8.3.0",
"@storybook/sveltekit": "^8.3.0",
"@sveltejs/adapter-static": "catalog:svelte",
"@sveltejs/kit": "catalog:svelte",
"@sveltejs/package": "^2.3.2",
"@sveltejs/vite-plugin-svelte": "catalog:svelte",
"@terrazzo/cli": "^0.0.11",
"@terrazzo/plugin-css": "^0.0.9",
"@types/postcss-pxtorem": "^6.0.3",
"@vitest/browser": "^2.0.5",
"autoprefixer": "^10.4.19",
"cpy-cli": "^5.0.0",
"date-fns": "^2.30.0",
"playwright": "^1.46.1",
"postcss": "^8.4.38",
"postcss-cli": "^11.0.0",
"postcss-minify": "^1.1.0",
"postcss-nesting": "^12.1.5",
"postcss-pxtorem": "^6.1.0",
"rimraf": "^6.0.1",
"storybook": "^8.2.7",
"storybook": "^8.3.0",
"storybook-dark-mode": "^4.0.2",
"svelte": "catalog:svelte",
"svelte-check": "catalog:svelte",
"vite": "catalog:"
"vite": "catalog:",
"vitest": "^2.0.5"
},
"peerDependencies": {
"svelte": "^4.0.0 || ^5.0.0-0"
Expand Down
1 change: 1 addition & 0 deletions packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"postcss.config.js",
"vite.config.js",
"vite.config.ts",
"vitest.workspace.ts",
"src/**/*.js",
"src/**/*.ts",
"src/**/*.svelte",
Expand Down
21 changes: 21 additions & 0 deletions packages/ui/vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { storybookTest } from '@storybook/experimental-addon-test/vitest-plugin';
import { storybookSveltekitPlugin } from '@storybook/sveltekit/vite-plugin';
import { defineWorkspace } from 'vitest/config';

export default defineWorkspace([
'vite.config.ts',
{
extends: 'vite.config.ts',
plugins: [storybookTest({ storybookScript: 'pnpm storybook' }), storybookSveltekitPlugin()],
test: {
browser: {
enabled: true,
headless: true,
name: 'chromium',
provider: 'playwright'
},
include: ['**/*.stories.?(m)[jt]s?(x)'],
setupFiles: ['./.storybook/vitest.setup.ts']
}
}
]);
Loading