vue.js - Vue Storybook Jest Addon 配置问题

标签 vue.js jestjs storybook

我想知道使用 jest 插件的人是否可以分享它的 Vue Storybook 配置,因为我似乎无法让它工作。我尝试过全局模式:

在 Storybook 的 config.js 中:

import { withTests } from '@storybook/addon-jest';

import results from '../.jest-test-results.json';

addDecorator(
  withTests({
    results,
  })
);

在我的故事中:

storiesOf('Elements/Tag', module)
  .addParameters({ jest: ['ThuleTag'] })
  .addDecorator(VueInfoAddon)
  .addDecorator(withTests({ results })('ThuleTag'))
  .add('Squared',
    withNotes(_notes)(() => ({
      components: {ThuleTag},
      template: _template,
      propsDescription: {
        size: 'medium / small / mini',
        type: 'success / info/warning / danger'
      }
    })),
  )

我收到此错误:

TypeError: Object(...)(...).addParameters is not a function

我也尝试过本地方式: 在我的故事中:

import { storiesOf } from '@storybook/vue'
import { withNotes } from '@storybook/addon-notes'
import results from '../../../jest-test-results.json'
import { withTests } from '@storybook/addon-jest'
import ThuleTag from '../../components/ui/elements/ThuleTag.vue'

let _notes = `A simple wrapper for the Elements el-tag, that accepts the same <i>type</i> and <i>size</i> props`

let _template = `<thule-tag
  size="small"
  key="name">Tag Namez
</thule-tag>`

storiesOf('Elements/Tag', module)
  .addDecorator(withTests({ results }))
  .add('Squared',
    withNotes(_notes)(() => ({
      components: {ThuleTag},
      template: _template,
      propsDescription: {
        size: 'medium / small / mini',
        type: 'success / info/warning / danger'
      }
    })),
    {
      jest: ['ThuleTag.test.js'],
    }
  )

这里我得到这个错误:

Error in render: "TypeError: Cannot read property '__esModule' of undefined"

“测试”选项卡显示以下消息:

This story has tests configured, but no file was found

有人可以指出我到底出了什么问题吗?

最佳答案

Vue.js 目前似乎不支持 Storybook Jest 插件 https://github.com/storybooks/storybook/blob/master/ADDONS_SUPPORT.md

关于vue.js - Vue Storybook Jest Addon 配置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52588890/

相关文章:

jestjs - 如何测试 react-native 方法?

javascript - Storybook 的迁移

vue.js - 将集合复制出 vuex 状态以防止突变是标准做法吗?

javascript - 如何将一个 Vue 组件中的所有字段与另一个组件一起验证(使用 Vee-Validate)?

node.js - 无法测试 mongo 聚合 MongoError : Unrecognized pipeline stage name: '$set'

javascript - 如何测试Nodejs请求回调监听器?

javascript - Storybook 5.2 (CSF) - 如何添加react-router-dom链接 - "You should not use <Link> outside a <Router>"

reactjs - Storybook 在 React、Next.JS、Typescript 项目中找不到组件

javascript - 使用 vue-router 给出 "Cannot find element #app"和 "TypeError: Cannot read property ' matched' of undefined"错误

javascript - 我如何使用 jest 在 vuejs 中测试计算属性?