Skip to content
Snippets Groups Projects
Unverified Commit 86fc8767 authored by BITARD Michaël's avatar BITARD Michaël Committed by GitHub
Browse files

chore(ui): update @storybook/testing-vue3 to support storybook 7 (#621)

parent b9e3aa3f
Branches
Tags
No related merge requests found
This diff is collapsed.
......@@ -31,7 +31,7 @@
"@storybook/addon-styling": "^1.3.0",
"@storybook/builder-vite": "^7.0.22",
"@storybook/testing-library": "^0.2.0",
"@storybook/testing-vue3": "^0.0.2",
"@storybook/testing-vue3": "^1.0.0",
"@storybook/vue3": "^7.0.22",
"@storybook/vue3-vite": "^7.0.22",
"@testing-library/vue": "^7.0.0",
......
......@@ -2,7 +2,6 @@ import { describe, expect, test, vi } from 'vitest'
import type { Meta, StoryFn } from '@storybook/vue3'
import { render } from '@testing-library/vue'
import { composeStories } from '@storybook/testing-vue3'
import type { ContextedStory } from '@storybook/testing-vue3/dist/types'
import { h } from 'vue'
type StoryFile = {
......@@ -26,9 +25,8 @@ vi.mock('vue-router', () => ({
vi.mock('vuex', () => ({ useStore: vi.fn() }))
const compose = (entry: StoryFile) => {
const compose = (entry: StoryFile): ReturnType<typeof composeStories<StoryFile>> => {
try {
// @ts-ignore waiting for https://github.com/storybookjs/testing-vue3/issues/10
return composeStories(entry)
} catch (e) {
throw new Error(`Un fichier est probablement mal formaté ${JSON.stringify(entry)}, ${e}`)
......@@ -42,7 +40,7 @@ describe('Storybook Tests', async () => {
})
)('$name', ({ name, storyFile, filePath }) => {
test.skipIf(name?.includes('NoStoryshots')).each(
Object.entries<ContextedStory<unknown>>(compose(storyFile))
Object.entries(compose(storyFile))
.map(([name, story]) => ({ name, story }))
.filter(env => name?.includes('NoStoryshots') || !env.name?.includes('NoSnapshot'))
)('$name', async value => {
......@@ -53,6 +51,7 @@ describe('Storybook Tests', async () => {
components: { 'router-link': (props, { slots }) => h('a', { ...props, type: 'primary', to: JSON.stringify(props.to).replaceAll('"', '') }, slots) },
},
})
await new Promise<void>(resolve => setTimeout(() => resolve(), 1))
expect(mounted.html()).toMatchFileSnapshot(`./${filePath.replace(/\.[^/.]+$/, '')}_snapshots_${value.name}.html`)
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment