Sli*_*lim 47 eslint jestjs eslint-config-airbnb eslintrc
我jest v24.7.1在我的项目中安装了:
npm install jest -D
Run Code Online (Sandbox Code Playgroud)
然后我开始编写一些测试文件,但是我收到了这些 eslint 错误:
'describe' is not defined. eslint (no-undef)
'it' is not defined. eslint (no-undef)
'expect' is not defined. eslint (no-undef)
Run Code Online (Sandbox Code Playgroud)
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: {}
};
Run Code Online (Sandbox Code Playgroud)
我应该添加另一个规则或插件来解决这个问题吗?
Avi*_*Avi 125
在.eslintrc.js文件中添加以下行
"env": {
"jest": true
}
Run Code Online (Sandbox Code Playgroud)
或者
{
"plugins": ["jest"]
},
"env": {
"jest/globals": true
}
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请查看此处,它也定义了相同的内容。
希望你安装了eslint-plugin-jestpackage.If 不请通过
文档。
配置 ESLint 的所有配置细节。
| 归档时间: |
|
| 查看次数: |
17575 次 |
| 最近记录: |