開発覚書はてな版

個人的な開発関連の備忘録

【Jest】JestをVSCodeでデバッグする

概要

Visual Studio CodeでJestをデバッグするための設定を記載します。 基本的には以下のURLの通りです。

github.com

実行環境

  • Node.js 10.x
  • Yarn 1.12.x

使用ライブラリ

  • TypeScript 3.2.x
  • Jest 23.6.x
  • ts-jest 23.10.x

launch.json の設定

以下の設定を ./.vscode/launch.json に記述する。

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Jest All",
      "program": "${workspaceFolder}/node_modules/.bin/jest",
      "args": ["--runInBand"],
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "disableOptimisticBPs": true,
      "windows": {
        "program": "${workspaceFolder}/node_modules/jest/bin/jest",
      }
    }
  ]
}

実行結果

f:id:kakkoya:20190126144934p:plain