我想知道是否有人使用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"Tests选项卡中显示以下消息:
This story has tests configured, but no file was found有没有人能告诉我哪里搞砸了?
发布于 2019-01-10 15:16:45
看起来现在https://github.com/storybooks/storybook/blob/master/ADDONS_SUPPORT.md不支持Vue.js的故事书jest插件
发布于 2019-01-18 16:15:44
好的,关于第一个错误
Error in render: "TypeError: Cannot read property '__esModule' of undefined"我认为你应该检查一下你的babel-config,你似乎忘记了你的框架的一些预设。
关于第二个问题
This story has tests configured, but no file was found有两种可能的解决方案:
在storybook-jest库的index.js中使用适当版本的Jest和storybook/addon-jest
如果(testFiles && !testFiles.disable) { //todo:这里应该是你的故事书黑客options.results = options.tests.testResults;options.results.testResults = options.results;emitAddTests({ kind: kind,story: story,testFiles: testFiles,options: options });}
https://stackoverflow.com/questions/52588890
复制相似问题