Jest / ESLint失败未定义

问题描述

我刚刚用npx react-native init生成了一个新项目,ESLint在我的一个测试文件中抱怨:

   9:1   error  'describe' is not defined    no-undef
  12:5   error  'beforeEach' is not defined  no-undef
  16:5   error  'afterEach' is not defined   no-undef
  20:5   error  'test' is not defined        no-undef
  28:17  error  'fail' is not defined        no-undef
  30:13  error  'expect' is not defined      no-undef

基于docs和此thread,我添加了:

env: {
    jest: true,},

到我的.eslintrc.js文件中。但是,ESLint仍在抱怨:

  28:17  error  'fail' is not defined  no-undef

有人有经验并解决过这个问题吗?

以下是package.json中最有趣的依赖项版本:

"babel-jest": "^26.5.2","jest": "^26.5.3",

解决方法

好吧,事实证明Jest使用了茉莉花的fail()

通过添加Jasmine更新了.eslintrc.js,它可以正常工作。没有更多错误。

env: {
    jasmine: true,jest: true,},

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...