Vue.js Vue Storybook Jest加载项配置问题

Vue.js Vue Storybook Jest加载项配置问题,vue.js,jestjs,storybook,Vue.js,Jestjs,Storybook,我想知道是否有人使用jest插件可以共享它的Vue Storybook配置,因为我似乎无法让它工作。我尝试过全局模式: 在故事书的config.js中: import { withTests } from '@storybook/addon-jest'; import results from '../.jest-test-results.json'; addDecorator( withTests({ results, }) ); 在我的故事里: storiesOf('E

我想知道是否有人使用jest插件可以共享它的Vue 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
Error in render: "TypeError: Cannot read property '__esModule' of undefined"
我也尝试过当地的方式: 在我的故事中:

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'],
    }
  )
“测试”选项卡显示以下消息:

This story has tests configured, but no file was found

有人能告诉我是什么搞砸了吗?

看来Vue.js目前不支持storybook jest插件 好的,关于第一个错误

Error in render: "TypeError: Cannot read property '__esModule' of undefined"
我认为您应该检查您的babel配置,似乎您忘记了框架的一些预设

关于第二个问题

This story has tests configured, but no file was found
这个问题发生在Jest和storybook/addon Jest想要使用equals api,但他们不能。在Jest的最新版本中,输出文件结构有
options.testResults
,但storybook/addon Jest需要
options.results
&
options.results.testResults

有两种可能的解决方案:

  • 使用适当版本的Jest和storybook/addon Jest
  • 在storybook jest库的index.js中应用huck,smth就是这样

    if (testFiles && !testFiles.disable) {
      //todo: HERE should be your storybook hack
      options.results = options.tests.testResults;
      options.results.testResults = options.results;
        emitAddTests({
        kind: kind,
        story: story,
        testFiles: testFiles,
        options: options
      });
    }