0
0

More than 1 year has passed since last update.

VSCode の Code Runner で Jest のテストを実行する

Last updated at Posted at 2022-10-13

調べると Jest というそのものズバリな拡張が存在するが、
Code Runner ユーザーであれば ↑ を入れる必要はなく、下記の設定を書くだけで良い。

settings.json
"code-runner.executorMapByGlob": {
    "*.test.ts" : "npx jest $fullFileName",
    "*.spec.ts" : "npx jest $fullFileName",
    "*.test.js" : "npx jest $fullFileName",
    "*.spec.js" : "npx jest $fullFileName"
}

余談だが、デフォルトの出力は色がつかず Jest の結果が見づらいので、出力をターミナルに指定しておくと色がついて見やすい。

settings.json
"code-runner.runInTerminal": true,
0
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
0
0