Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

vscode breakpoints not being hit in TS mocha tests

オープン
#280 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
docker-compose, node.js, typescript, vscode

調査の方向性

docker-compose の定義、VS Code の起動構成、package.json の test-brk コマンドから始めます。生成されたソースと source maps に使用されるパスを含め、ホストとコンテナでのテスト実行を比較します。docker-compose exec 経由でテストを実行したときに Mocha のブレークポイントが解決されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
JavaScript
スター
2.2k
フォーク
221
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

evanw/node-source-map-support のほかの issue

evanw/node-source-map-support の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。