jestjs - 无法从 xxx.vue jest 收集报道
问题描述
我运行时得到了这个日志yarn test
。我试图删除 node_modules,重新安装所有依赖项并运行yarn test --no-cache
,但它不起作用。
yarn run v1.22.10
$ jest --coverage
PASS __test__/src/App.test.ts
√ test1 (2 ms)
Running coverage on untested files...Failed to collect coverage from D:\svn-frontend-admin\src\App.vue
ERROR: Unexpected token ] in JSON at position 6179
STACK: SyntaxError: Unexpected token ] in JSON at position 6179
这些是我的配置文件
// jest.config.js
module.exports = {
......
preset: 'ts-jest',
collectCoverage: true,
collectCoverageFrom: ['src/**/*.{js,ts,vue}', 'src/*.{ts,vue}'],
coverageReporters: ['clover'],
moduleFileExtensions: ['js', 'ts', 'tsx', 'json', 'vue'],
transform: {
'.*\\.(vue)$': 'vue-jest',
'^.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': require.resolve('jest-transform-stub'),
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.jsx?$': 'babel-jest',
},
transformIgnorePatterns: [
'node_modules/(?!(@babel/runtime-corejs3/helpers/esm/.*)|(vue/dist/.*))'
],
......
};
解决方案
推荐阅读
- javascript - ajax 函数在不应该时仍然刷新页面
- reactjs - 如何将模拟对象传递给酶模拟功能?
- python - 销毁所有子窗口
- regex - 找出正则表达式中的最后一个数字
- visual-studio-code - 在 Visual Studio Code 中绘制箭头和符号
- java - 我有一个 svg 文件内容,我想根据匹配的子字符串删除一个字符串
- javascript - 单击按钮后显示 HTML/CSS 类
- javascript - 处理 webpack 动态导入承诺拒绝的正确方法是什么?
- database - 我应该如何创建产品属性数据?
- php - 如何从 JSON 编码字符串中提取特定数据