vite+vue3+jest搭建报错
来源:2-4 Jest 的简单配置

yanchang
2020-08-31
1.报错信息
2. package.json
{
“name”: “vite-jest”,
“version”: “0.0.0”,
“scripts”: {
“dev”: “vite”,
“build”: “vite build”,
“test”: “jest”
},
“dependencies”: {
“vue”: “^3.0.0-rc.1”
},
“devDependencies”: {
"@babel/core": “^7.11.4”,
"@babel/preset-env": “^7.11.0”,
"@types/jest": “^26.0.10”,
"@vue/compiler-sfc": “^3.0.0-rc.9”,
"@vue/test-utils": “^2.0.0-beta.3”,
“babel-jest”: “^26.3.0”,
“jest”: “^26.4.2”,
“ts-jest”: “^26.3.0”,
“typescript”: “^4.0.2”,
“vite”: “^1.0.0-rc.1”,
“vue-jest”: “^5.0.0-alpha.1”
}
}
3. jest.config.js
module.exports = {
preset: ‘ts-jest’,
clearMocks: true,
testEnvironment: ‘jsdom’,
transformIgnorePatterns: ["/node_modules/"],
transform: {
’^.+\.vueKaTeX parse error: Expected 'EOF', got '\\' at position 25: …est',
'^.+\̲\̲js’: ‘babel-jest’
},
moduleFileExtensions: [‘vue’, ‘js’, ‘json’, ‘jsx’, ‘ts’, ‘tsx’, ‘node’]
}
1回答
-
yanchang
提问者
2020-08-31
测试代码 import { mount } from '@vue/test-utils' import HelloWorld from './HelloWorld' describe('Component', () => { test('is a Vue instance', () => { const wrapper = mount(HelloWorld) expect(wrapper.isVueInstance()).toBeTruthy() }) })
022020-09-04
相似问题