LoginSignup
1
0

More than 3 years have passed since last update.

[exercism.io]VSCodeでJestのデバッグをする方法

Posted at

概要

exercism.ioのJavaScriptコースでJestのデバッグをする方法を紹介します。
といっても結局はVSCodeでJestのデバッグをする方法です。

方法

1.launch.jsonに以下の記述をする。
programのパスはjestの実行ファイルがある場所に変えてください。


{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Jest Debugger",
            "program": "${workspaceFolder}/javascript/list-ops/node_modules/.bin/jest",
            "args": [ "${fileBasenameNoExtension}" ],
            "cwd": "${workspaceFolder}/${relativeFileDirname}",
        }
    ]
}

2.デバッグしたいファイルを開いた状態でDebugを実行する

how to debug.png

解説

気が向いたときに補足します。

programがデバッグ実行時に呼ばれる処理です。
argsが処理が呼ばれる際に渡される引数です。

なのでデバッグ実行時にはjestに現在開いているファイル名を渡しています。

とりあえず雑に参考資料を貼っておきます。
https://code.visualstudio.com/docs/editor/variables-reference
https://code.visualstudio.com/Docs/editor/debugging

1
0
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
1
0