我有一个在docker容器中运行的节点项目,chrome-debugger通过端口9229连接到该容器。当使用实际应用程序(而不是运行测试套件)时,调试器会很好地显示错误/断点。
但是,当我从docker容器中运行npm run test:e2e
时,调试器命令,断点等将被完全忽略。测试套件可以运行,但不会中断。
诚然,我对docker和node还是陌生的,但是应用程序(而不是开玩笑的)断点有效的事实使我感到非常困惑。如果有人对如何从在chrome-debugger中工作的Docker容器中获得开玩笑的断点有任何想法(或与此相对的vs代码),我将不胜感激。下面的配置详细信息:
pf_debugger:
build: ./pf
image: pf_debugger
container_name: pf_debugger
working_dir: /www
ports:
- "9229:9229"
command: "npm run start:debug"
volumes:
- ./pf:/www
- node_modules:/www/node_modules
depends_on:
- "indy_pool"
- "pf"
networks:
- pf_network
# ...
"scripts":
"start:debug": "nodemon --config nodemon-debug.json",
"test:e2e": "jest --config ./test/jest-e2e.json",
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}
{
"watch": ["src"],
"ext": "ts",
"inspect": "0.0.0.0:9229",
"exec": "node --inspect=0.0.0.0:9229 --debug -r ts-node/register src/main.ts"
}
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Node: Nodemon",
"restart": true,
"sourceMaps": true,
"protocol": "inspector",
"address": "127.0.0.1",
"port": 9229,
"localRoot": "${workspaceRoot}/",
"remoteRoot": "/www/"
},
{
"type": "node",
"name": "e2e-tests",
"request": "launch",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"args": [
"--runInBand",
"--config=test/jest-e2e.json"
]
}
]
答案 0 :(得分:0)
作为参考,我解决了自己的问题。将--runInBand
附加到npm:test
命令可确保遵守断点