Hoa*_*Son 6 unit-testing vue.js jestjs babel-jest vuejs2
我遇到了错误,需要您的帮助。感谢您收看这个问题。
我的情况:我正在为我的项目配置Drone CI工具,当我在drone.yml上运行单元测试时得到了这个。
Validation Error:
Module <rootDir>/node_modules/vue-jest in the transform option was not found.
Configuration Documentation:
https://jestjs.io/docs/configuration.html
Run Code Online (Sandbox Code Playgroud)
这是我的 jest.conf.js
transform: {
"^.+\\.js$": "babel-jest",
".*\\.vue$": "<rootDir>/node_modules/vue-jest"
},
Run Code Online (Sandbox Code Playgroud)
我尝试过的
<rootDir>/node_modules/
。但是我又犯了一个错误Module vue-jest in the transform option was not found.
。所以我认为这不是正确的解决方案Qba*_*ack 12
请注意vue-jest
当前(2022 年)以3 个并发包分发:
vue-jest
@vue/vue2-jest
@vue/vue3-jest
就我而言,我升级了一些依赖项,并且必须从 切换vue-jest
到@vue/vue3-jest
.
所以我的jest.config.js
必须相应改变:
module.exports = {
...
transform: {
"^.+\\.vue$": "@vue/vue3-jest",
},
...
}
Run Code Online (Sandbox Code Playgroud)
小智 6
npm install --save-dev vue-jest
Run Code Online (Sandbox Code Playgroud)
并重新运行您的测试
归档时间: |
|
查看次数: |
829 次 |
最近记录: |