首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Vue Storybook Jest插件配置问题

Vue Storybook Jest插件配置问题
EN

Stack Overflow用户
提问于 2018-10-01 18:12:11
回答 2查看 664关注 0票数 2

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

在Storybook的config.js中:

代码语言:javascript
复制
import { withTests } from '@storybook/addon-jest';

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

addDecorator(
  withTests({
    results,
  })
);

在我的故事里:

代码语言:javascript
复制
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'
      }
    })),
  )

我得到了这个错误:

代码语言:javascript
复制
TypeError: Object(...)(...).addParameters is not a function

我也尝试了当地的方法:在我的故事中:

代码语言:javascript
复制
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'],
    }
  )

下面我得到了这个错误:

代码语言:javascript
复制
Error in render: "TypeError: Cannot read property '__esModule' of undefined"

Tests选项卡中显示以下消息:

代码语言:javascript
复制
This story has tests configured, but no file was found

有没有人能告诉我哪里搞砸了?

EN

回答 2

Stack Overflow用户

发布于 2019-01-10 15:16:45

看起来现在https://github.com/storybooks/storybook/blob/master/ADDONS_SUPPORT.md不支持Vue.js的故事书jest插件

票数 2
EN

Stack Overflow用户

发布于 2019-01-18 16:15:44

好的,关于第一个错误

代码语言:javascript
复制
Error in render: "TypeError: Cannot read property '__esModule' of undefined"

我认为你应该检查一下你的babel-config,你似乎忘记了你的框架的一些预设。

关于第二个问题

代码语言:javascript
复制
This story has tests configured, but no file was found

有两种可能的解决方案:

在storybook-jest库的index.js中使用适当版本的Jest和storybook/addon-jest

  • apply ,就像这样

如果(testFiles && !testFiles.disable) { //todo:这里应该是你的故事书黑客options.results = options.tests.testResults;options.results.testResults = options.results;emitAddTests({ kind: kind,story: story,testFiles: testFiles,options: options });}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52588890

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档