我在我的项目中使用以下命令安装了jest v24.7.1
:
npm install jest -D
然后我开始写一些测试文件,但是我得到了这些eslint错误:
'describe' is not defined. eslint (no-undef)
'it' is not defined. eslint (no-undef)
'expect' is not defined. eslint (no-undef)
eslintrc.js:
module.exports = {
env: {
browser: true,
es6: true
},
extends: ["airbnb", "prettier", "prettier/react"],
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly"
},
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: 2018,
sourceType: "module"
},
plugins: ["react"],
rules: {}
};
我应该添加另一个规则或插件来解决这个问题吗?
发布于 2019-04-23 17:36:08
在.eslintrc.js
文件中添加以下行
"env": {
"jest": true
}
或
{
"plugins": ["jest"]
},
"env": {
"jest/globals": true
}
有关更多详细信息,请查看here,它也定义了相同的内容。
希望你安装的是eslint-plugin-jest
package.If,而不是Documentation。
Configuring ESLint的所有配置详细信息。
发布于 2020-09-03 10:05:51
在文件头中添加以下注释行
/* globals describe, expect, it */
https://stackoverflow.com/questions/55807824
复制相似问题