10
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JestのテストコードをVScodeでデバッグする

Last updated at Posted at 2018-06-21

個人メモとして投稿。

まぁざっくり公式を見ればいいのだが、launch.jsonの記述がわりとアレ(別に動きはする)なのでよりシンプルに書いてみた。

..vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Jest Tests",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/node_modules/.bin/jest",
            "protocol": "inspector",
            "args": [ "--runInBand" ],
            "windows": {
                "program": "${workspaceRoot}/node_modules/jest/bin/jest.js"
            }
        }
    ]
}

環境上書き用の設定は存在するので、わざわざwindowsで書き換えする必要はありません。
この記述だとコンソールが自動で表示されないのですが、それが気に入らない人は下記の通り書いておけばいいでしょう。

..vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Jest Tests",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/node_modules/.bin/jest",
            "protocol": "inspector",
            "args": [ "--runInBand" ],
            "windows": {
                "program": "${workspaceRoot}/node_modules/jest/bin/jest.js"
            },
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen"
        }
    ]
}
10
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?