-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: extend storybook config types from vue3-vite framework (#649)
Allows for type-safe usage of the new `docgen` setting added in Storybook v8 - https://storybook.js.org/docs/8.0/get-started/vue3-vite#using-vue-component-meta Fixes storybook-vue/storybook-nuxt#103. --------- Signed-off-by: Ryan Leckey <ryan@calaxy.com> Co-authored-by: Tobias Diez <code@tobiasdiez.de>
- Loading branch information
1 parent
c40a4dd
commit a816e6e
Showing
7 changed files
with
89 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { describe, expectTypeOf, test } from 'vitest' | ||
import type { StorybookConfig } from './types' | ||
|
||
describe('StorybookConfig', () => { | ||
test('should restrict framework name', () => { | ||
expectTypeOf<StorybookConfig>() | ||
.toHaveProperty('framework') | ||
.extract<string>() | ||
.toEqualTypeOf<'@storybook-vue/nuxt'>() | ||
expectTypeOf<StorybookConfig>() | ||
.toHaveProperty('framework') | ||
.extract<{ name: string }>() | ||
.toHaveProperty('name') | ||
.toEqualTypeOf<'@storybook-vue/nuxt'>() | ||
}) | ||
test('should restrict builder name', () => { | ||
expectTypeOf<StorybookConfig>() | ||
.toHaveProperty('core') | ||
.exclude<undefined>() | ||
.toHaveProperty('builder') | ||
.extract<string>() | ||
.toEqualTypeOf<'@storybook/builder-vite'>() | ||
|
||
expectTypeOf<StorybookConfig>() | ||
.toHaveProperty('core') | ||
.exclude<undefined>() | ||
.toHaveProperty('builder') | ||
.extract<{ name: string }>() | ||
.toHaveProperty('name') | ||
.toEqualTypeOf<'@storybook/builder-vite'>() | ||
}) | ||
test('should allow setting docgen option', () => { | ||
const _config: StorybookConfig = { | ||
stories: [], | ||
framework: { | ||
name: '@storybook-vue/nuxt', | ||
options: { | ||
docgen: 'vue-component-meta', | ||
}, | ||
}, | ||
} | ||
}) | ||
test('should allow setting staticDirs', () => { | ||
const _config: StorybookConfig = { | ||
stories: [], | ||
framework: '@storybook-vue/nuxt', | ||
staticDirs: ['public'], | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineVitestConfig } from '@nuxt/test-utils/config' | ||
|
||
export default defineVitestConfig({ | ||
test: { | ||
typecheck: { | ||
enabled: true, | ||
// Don't fail the test if typecheck of source files fails for the moment | ||
ignoreSourceErrors: true, | ||
}, | ||
}, | ||
}) |