前言
今天学习 jest 的 vue-test-utils 的配置及使用。
- 报错原因为 jest 全局变量
- git 提交代码报错,使用除了参考链接里的解决方案,正好复习一下之前学习的 Git Hooks:
-
错误 git 日志
git-error-1675323308267
... ✖ vue-cli-service lint found some errors. Please fix them and try committing again. error: 'describe' is not defined (no-undef) at __tests__\unit\HelloWorld.test.js:5:1: ... error: 'it' is not defined (no-undef) at __tests__\unit\HelloWorld.test.js:6:3: ... pre-commit hook failed (add --no-verify to bypass)
解决方案
.eslintrc.js
module.exports = {
env: {
jest: true // 添加这一行
},
}
就不报错了。
- 复习 Git Hooks
参考链接
git提交代码会报 vue-cli-service lint found some errors. Please fix them and try committing again