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()
  })
})


0
2
Dell
回复
yanchang
好的!
2020-09-04
共2条回复

前端要学的测试课 从Jest入门到 TDD/BDD双实战

自动化测试实战 Vue / React 项目,让技术水平和架构思维双提升

1434 学习 · 350 问题

查看课程