Npm VSCode Launch.json--使用全局安装的jest
我的当前工作区结构如下 每个文件夹(auth、client、tickets、common)都有自己的node_modules文件夹(我正在编写microservices)。.vscode文件夹有一个launch.json文件 我的票证文件夹如下 我希望能够将以下脚本添加到launch.jsonNpm VSCode Launch.json--使用全局安装的jest,npm,visual-studio-code,jestjs,vscode-debugger,Npm,Visual Studio Code,Jestjs,Vscode Debugger,我的当前工作区结构如下 每个文件夹(auth、client、tickets、common)都有自己的node_modules文件夹(我正在编写microservices)。.vscode文件夹有一个launch.json文件 我的票证文件夹如下 我希望能够将以下脚本添加到launch.json { "type": "node", "request": "launch", &q
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"${fileBasenameNoExtension}",
"--config",
"${workspaceRoot}/jest.config.js"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true
},
"program": "/usr/local/bin/jest",
也就是说,我希望能够在当前打开的测试文件上使用调试器
但是,正如你所看到的,我们有
根工作空间文件夹没有节点模块。Jest分别安装在每个微服务中
我做了一个类似${workspaceFolder}/tickets/node_modules/.bin/jest的黑客程序。但这看起来很混乱——如果我在auth文件夹中运行测试呢?会有用的,但是。。。乱七八糟的
或者,我可以指向我的jest全球安装。。。但是我似乎找不到包含它的正确语法(我知道我的全局npm安装包在这里:/usr/local/lib/node_modules)
你们有什么解决办法吗?谢谢你的帮助/建议,谢谢 打开终端并将jest作为全球可用的软件包安装
$ npm install jest --global
$ jest --version
26.6.3
$ whereis jest
/usr/local/bin/jest
更新您的launch.json
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"${fileBasenameNoExtension}",
"--config",
"${workspaceRoot}/jest.config.js"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true
},
"program": "/usr/local/bin/jest",
全局安装的Jest不应该作为没有任何路径的
Jest
提供吗?这就是全球安装NPM包的目的。