gpt4 book ai didi

visual-studio-code - VSCode 说找不到 jest.js 文件

转载 作者:行者123 更新时间:2023-12-02 20:08:17 31 4
gpt4 key购买 nike

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

enter image description here

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

错误消息显示:

Cannot find jest.js file!

这是怎么回事?我该如何摆脱它?它并不妨碍我使用编辑器,但是将这些行随机插入到源代码的各个位置是很烦人的。

最佳答案

这是对我有用的 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

关于visual-studio-code - VSCode 说找不到 jest.js 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47575916/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com