【问题标题】:VSCode says it cannot find jest.js fileVSCode 说找不到 jest.js 文件
【发布时间】:2018-05-14 12:39:39
【问题描述】:

VSCode 最近开始在我的源文件中显示一些额外的行,带有Debug 标签。这些行不是我的代码的一部分,因为我可以看到它是编辑器在我的代码渲染中插入的一些行之间的内容。

每当我单击其中一个时(因为当我将鼠标光标移到它们上方时会出现链接),我会收到可以在屏幕截图顶部看到的浮动错误消息。

错误信息说:

Cannot find jest.js file!

这是关于什么的,我该如何摆脱它?它不会阻止我使用编辑器,但是将这些行随机插入到我的源代码的各个位置很烦人。

【问题讨论】:

  • 很明显来自一个插件,可能是Jest。你安装了哪些插件?任何可能尝试自己实现 Jest 的测试运行器?
  • 是的,它是 Jest 扩展。我卸载它,一切正常。我重新安装它,我得到了错误。我不确定我是否有时间并愿意进一步调查。扩展并没有给我任何我不能没有的东西,所以我暂时放弃它。

标签: visual-studio-code jestjs


【解决方案1】:

这是对我有用的create-react-app.vscode/launch.json 配置:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug CRA Tests",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts",      
      "args": [
        "test",
        "--runInBand",
        "--no-cache",
        "--env=jsdom"
      ],
      "cwd": "${workspaceRoot}",
      "protocol": "inspector",
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen"
    }
  ]
}

加上我.vscode/settings.json中的以下设置

{
  "jest.pathToJest": "node_modules/jest/bin/jest.js"
}

对类似问题的一些额外参考:

参考:

这是为我解决问题的问题: * https://github.com/jest-community/vscode-jest/issues/136

【讨论】:

    猜你喜欢
    • 2019-05-05
    • 2011-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-04
    • 2022-11-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多