Nodejs test runner setup in VSCode

Image of Author
September 20, 2023 (last updated September 16, 2024)

This note is for setting up the Nodejs test runner in VSCode. For my notes on the test runner itself see Nodejs#Nodejs test runner

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "all",
      "type": "shell",
      "command": "node --test"
    },
    {
      "label": "file",
      "type": "shell",
      "command": "node --test ${file}",
      "runOptions": {
        "reevaluateOnRerun": false
      }
    },
    {
      "label": "line",
      "type": "shell",
      "command": "node --test --test-name-pattern \"${selectedText}\" ${file}",
      "runOptions": {
        "reevaluateOnRerun": false
      }
    }
  ]
}