How to define test task

Besides naming the task to execute test you can set the isTestCommand property to true. Something like

{
   ...
   tasks: [{
      "taskName": "myTestTask",
      "isTestCommand": true,
      ...
   }]
}

This will also bind myTestTask to Ctrl+Shift+T


This has changed in the latest version of VS Code (1.47.0)

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Run tests",
      "group": "test", // <-- this will add this task to 'Run test task'
      "type": "shell",
      "command": "npm test"
    }
  ]
}

Looks like they changed the default behavior of the Ctrl+Shift+T keybinding in recent versions to reopen the last tab closed (like many browsers support). To view your current Keyboard Bindings, select the following menu option:

File > Preferences > Keyboard Shortcuts

If you want to change the Ctrl+Shift+T keybinding back to issuing your default test task, simply change the value of the command property in the following object:

{ "key": "ctrl+shift+t", "command": "workbench.action.reopenClosedEditor" }

to be: workbench.action.tasks.test, or you can assign the testing task to a different keybinding by adding the following line to your Default Keyboard Shortcuts config file:

{ "key": "<your keybinding here>", "command": "workbench.action.tasks.test" }