【发布时间】:2021-06-23 07:31:40
【问题描述】:
我有默认的 jest.config.js,但是当我想运行单元测试时,我收到一条错误消息:
验证错误: 未找到预设 @vue/cli-plugin-unit-jest/presets/typescript-and-babel。
我正在使用带有组合 API 插件和打字稿的 vue 2。
jest.config.js:
module.exports = {
preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel'
}
example.spec.ts:
import { shallowMount } from '@vue/test-utils'
import HelloWorld from '@/components/HelloWorld.vue'
describe('HelloWorld.vue', () => {
it('renders props.msg when passed', () => {
const msg = 'new message'
const wrapper = shallowMount(HelloWorld, {
props: { msg }
})
expect(wrapper.text()).toMatch(msg)
})
})
【问题讨论】:
-
你的项目本地安装了this plugin吗?
-
是的,我已将其安装为开发依赖项。
标签: typescript vue.js jestjs