【发布时间】:2021-05-17 18:33:36
【问题描述】:
我无法在运行笑话测试时附加 VS Code 调试器。我尝试使用我找到的不同替代方案配置 launch.json 文件,但它们总是失败并显示以下错误消息,抱怨 node_modules 文件夹中的文件:
Debugger attached.
Waiting for the debugger to disconnect...
local\path\to\node_modules\.bin\jest:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
我的package.json 文件有以下配置:
"scripts": {
"compile": "tsc",
"run": "node ./build/index.js",
"execute": "tsc && node ./build/index.js",
"test": "tsc && jest ./build/tests/*"
},
"author": "roguib",
"license": "ISC",
"dependencies": {
"@types/jest": "^26.0.20",
"ts-jest": "^26.5.1",
"ts-node": "^9.1.1"
},
"devDependencies": {
"@types/node": "^14.14.21",
"jest": "^26.6.3"
}
我的launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": ["--inspect-brk", "${workspaceRoot}/node_modules/.bin/jest", "--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
如果有帮助,执行 npm run test 通常会运行我的 jest 测试,所以我不确定它是否与 jest 本身有关。
【问题讨论】:
标签: node.js typescript jestjs ts-jest ts-node