From 3646ab51525cec65cc7d59bc86ce575a664bc63c Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Fri, 16 Aug 2024 11:10:11 +0200 Subject: [PATCH] increase test coverage in storybook ui --- code/.storybook/vitest.config.ts | 2 +- .../components/HighlightElement/HighlightElement.stories.tsx | 4 ++-- code/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/.storybook/vitest.config.ts b/code/.storybook/vitest.config.ts index a9e26b6ddba..4e7c8fdd87d 100644 --- a/code/.storybook/vitest.config.ts +++ b/code/.storybook/vitest.config.ts @@ -33,7 +33,7 @@ export default mergeConfig( include: [ // TODO: test all core and addon stories later // './core/**/components/**/*.{story,stories}.?(c|m)[jt]s?(x)', - '../addons/interactions/src/**/*.{story,stories}.?(c|m)[jt]s?(x)', + '../addons/**/src/**/*.{story,stories}.?(c|m)[jt]s?(x)', ], exclude: [ ...defaultExclude, diff --git a/code/addons/onboarding/src/components/HighlightElement/HighlightElement.stories.tsx b/code/addons/onboarding/src/components/HighlightElement/HighlightElement.stories.tsx index 0a6cb70831b..7cb0c52b011 100644 --- a/code/addons/onboarding/src/components/HighlightElement/HighlightElement.stories.tsx +++ b/code/addons/onboarding/src/components/HighlightElement/HighlightElement.stories.tsx @@ -1,7 +1,7 @@ import React from 'react'; import type { Meta, StoryObj } from '@storybook/react'; -import { expect, within } from '@storybook/test'; +import { expect, waitFor, within } from '@storybook/test'; import { HighlightElement } from './HighlightElement'; @@ -38,7 +38,7 @@ export const Default: Story = { play: async ({ canvasElement }) => { const canvas = within(canvasElement.parentElement!); const button = canvas.getByRole('button'); - await expect(button).toHaveStyle('box-shadow: rgba(2,156,253,1) 0 0 2px 1px'); + await waitFor(() => expect(button).toHaveStyle('box-shadow: rgba(2,156,253,1) 0 0 2px 1px')); }, }; diff --git a/code/package.json b/code/package.json index 412f78c1ddd..98b8d1709af 100644 --- a/code/package.json +++ b/code/package.json @@ -48,7 +48,7 @@ "storybook:ui": "NODE_OPTIONS=\"--preserve-symlinks --preserve-symlinks-main\" ./lib/cli/bin/index.cjs dev --port 6006 --config-dir ./.storybook", "storybook:ui:build": "NODE_OPTIONS=\"--preserve-symlinks --preserve-symlinks-main\" ./lib/cli/bin/index.cjs build --config-dir ./.storybook --webpack-stats-json", "storybook:ui:chromatic": "../scripts/node_modules/.bin/chromatic --build-script-name storybook:ui:build --storybook-base-dir ./ --exit-zero-on-changes --exit-once-uploaded", - "storybook:vitest": "yarn test --project storybook-ui", + "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",