storybookjs / testing-vue3

Testing utilities that allow you to reuse your stories in your unit tests
16 stars 7 forks source link

Support story format CSF v3.0 #8

Closed maxicasa closed 1 year ago

maxicasa commented 2 years ago

I'm write the stories with new CSF v3.0 format, but testing-vue3 support only the previous CSF format. When will available the support to the new format?

Component example:

export default {
  title: "Components/Button",
  component: Button
} as Meta;

export const Basic: Story = {
  parameters: {
    docs: {
      source: {
        code: `<Button>Example</Button>`
      },
      description: {
        component: "Customizable button with content."
      }
    }
  }
};

I get this error, when trying to use CSF 3.0 stories with composeStories.

 packages/components/src/button/Button.test.ts [ packages/components/src/button/Button.test.ts ]
Error: Cannot compose story due to invalid format. @storybook/testing-vue expected a function but received object instead.
 ❯ composeStory node_modules/.pnpm/@storybook+testing-vue3@0.0.2_i2pafdhxvhztb374fr7cj3wsfq/node_modules/@storybook/testing-vue3/dist/testing-vue3.cjs.development.js:140:11
 ❯ node_modules/.pnpm/@storybook+testing-vue3@0.0.2_i2pafdhxvhztb374fr7cj3wsfq/node_modules/@storybook/testing-vue3/dist/testing-vue3.cjs.development.js:194:23
 ❯ Proxy.composeStories node_modules/.pnpm/@storybook+testing-vue3@0.0.2_i2pafdhxvhztb374fr7cj3wsfq/node_modules/@storybook/testing-vue3/dist/testing-vue3.cjs.development.js:191:49
 ❯ packages/components/src/button/Button.test.ts:8:18
      6| import { Button } from "./index";
      7| 
      8| const { Basic } = composeStories(stories);
       |                  ^
      9| 
     10| describe("Basic tests", () => {

Environment

Additional context

{ ... "@storybook/vue3": "^6.5.9", "@storybook/testing-vue3": "^0.0.2", "@storybook/builder-vite": "^0.2.0", "@testing-library/vue": "^6.6.1", "vitest": "^0.18.1", ... }

yannbf commented 1 year ago

Hey there, this is now supported in version 1.0.0 of this package. Keep in mind that it requires Storybook 7.0.0!