僕が Visual Studio Code を利用して開発しているときの設定。 こうすると ts-nodeとjestの双方でdebuggerを利用できる。
※ 他に良い方法があれば :pray:
設定ファイル
{ "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Debug Jest", "preLaunchTask": "build", "program": "${workspaceRoot}/node_modules/jest/bin/jest.js", "args": [ "${file}", // 現在のプロセスで逐次テストを実行していく設定. // この設定をしないと複数のchildプロセスでテストを実行するらしい // debuggingのために有用とのことだったので、この設定を有効にした // https://facebook.github.io/jest/docs/en/cli.html#runinband // debugの際はcacheを無効にした。 // cacheを無効にすると、2倍くらい遅くなるらしい。 "--runInBand", "--no-cache" ], "cwd": "${workspaceRoot}", "console": "integratedTerminal" }, { "name": "ts-node[debug]", "type": "node", "request": "launch", "program": "${workspaceFolder}/node_modules/ts-node/dist/bin.js", "args": [ "${relativeFile}" ], "console": "integratedTerminal" } ] }
{ "version": "2.0.0", "tasks": [ { "label": "build", "type": "shell", "command": "npx tsc" } ] }