vscode breakpoints not being hit in TS mocha tests
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 25/100
- Type d'issue
- Bug
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- docker-compose, node.js, typescript, vscode
- Domaine
- developer-experience, devops, testing
Piste de recherche
Commencez par la définition de docker-compose, les configurations de lancement de VS Code et la commande test-brk de package.json. Comparez les exécutions des tests sur l’hôte et dans le conteneur, y compris les chemins utilisés pour les sources générées et les source maps ; le travail est considéré comme terminé lorsque les points d’arrêt de Mocha sont résolus lors de l’exécution des tests via docker-compose exec.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Hi
I have a boilerplate express project in TS.
My setup is that I run the project and the build tool chain inside a docker container; the goal being simple replication of dev environments across multiple machines.
The container is managed by the following compose definition:
services:
node:
image: node:12.18.1
hostname: app-node-dev
command: npm run dev
environment:
- HOME=/home/me/workspace/service-kit/sk-base-nodejs
- NODE_ENV=development
ports:
- 8080:8080
- 18080:18080
- 9222:9222
- 9321:9321
volumes:
- ../..:/home/me/workspace/service-kit/sk-base-nodejs:rw
- /etc/group:/etc/group:ro
- /etc/passwd:/etc/passwd:ro
- /etc/shadow:/etc/shadow:ro
- /tmp:/tmp:rw
user: ${_UID}:${_GID}
working_dir: /home/me/workspace/service-kit/sk-base-nodejs
stdin_open: true
tty: true
restart: unless-stopped
Note that I am using the working dir as an exact copy of the absolute path on my host machine.
Previously I was mounting to /workspace but I thought that the unmatching paths may be causing the problem; apparently not.
I mount the passwd/shadow so that I can maintain the file ownership.
I have the following vscode launch configuration to attach to the running app instance:
{
"type": "node",
"request": "attach",
"name": "SK - Attach to Node",
"protocol": "inspector",
"port": 9222,
"restart": true,
"localRoot": "${workspaceFolder}/dist",
"remoteRoot": "/workspace/dist",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"skipFiles": [
"<node_internals>/**/*.js",
]
},
This works great. I can attach and hit breakpoints as expected.
However the problem is when I execute mocha tests via the following launch configuration:
{
"type": "node",
"request": "launch",
"name": "SK - Mocha Tests Bak",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "make",
"runtimeArgs": [
"npm",
"run",
"test-brk"
],
"env": {
"NODE_ENV": "test-external",
},
"port": 9321,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"protocol": "inspector",
"sourceMaps": true,
},
One key unusual thing here is that I am executing make npm run test-brk. This make command translates to a docker-compose exec that runs npm run test-brk within the running container.
The test-brk command in the package.json is defined as:
"test-brk": "mocha --require node_modules/ts-node/register --inspect-brk=0.0.0.0:9321 --debug-brk --exit test/**/*.spec.ts",
When I launch the debug config in vscode the tests launch and execute and pass; but the breakpoints are not hit.
`Breakpoint ignored because generated source not found (source map problem?)`
Here is where things get interesting. The above execution runs the npm run test-brk within the container. If I install node on my dev machine and execute npm run test-brk from my host then everything works as expected - the tests run and the breakpoints are hit.
In short - it appears that vscode cannot find the source maps if I run mocha from within the container. But the source maps are found if I run mocha from on the host.
Is there something that I am missing that gets generated within the container that vscode cannot access? even though the workspace folder is mounted?
I would really appreciate any input on this.
Node is version 12.18.1
Source map support 0.5.19
- Langage dominant
- JavaScript
- Étoiles
- 2.2k
- Forks
- 220
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de evanw/node-source-map-support
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
evanw/node-source-map-support#344 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
evanw/node-source-map-support#343 ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
evanw/node-source-map-support#337 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 20/100
evanw/node-source-map-support#333 ·
-
Provide esm versionOuverte
Difficulté 4/5 3-5 jours Accessibilité débutants 28/100
evanw/node-source-map-support#330 · 2 commentaires · 9 réactions ·
Toutes les issues de evanw/node-source-map-support
Issues similaires
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
mongoosejs/mquery#142 ·
-
Site Suggestion: bullseyeOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 1 jour
-
Add toro4n to the data modeling toolsPeut-être pris @henriklantzhedstrom-prog l’a pris aujourd’hui. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 62/100
neo4j/docs-getting-started#546 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 25 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
libnativeapi/nativeapi#21 ·