Skip to content

Instantly share code, notes, and snippets.

@brianlow
Last active May 25, 2020 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianlow/17c368e031c696cab218613a835342e3 to your computer and use it in GitHub Desktop.
Save brianlow/17c368e031c696cab218613a835342e3 to your computer and use it in GitHub Desktop.
Tasks for VSCode + MiniTest

Press CMD+r to run tests in a VSCode terminal:

  • Run test at cursor
  • Run all test in the current file
  • Re-run the last test run

To install:

  • VSCode -> command palette -> Configure Task.. -> paste in tasks.json
  • VSCode -> command palette -> Open Keyboard Shortcuts (JSON) -> paste
[
  {
    "key": "cmd+r",
    "command": "workbench.action.tasks.runTask"
  },
]

Gotchas:

  • Should be able to bind separate shortcut to each action but no luck [1] [2]
{
"version": "2.0.0",
"tasks": [
{
"label": "Run test",
"type": "shell",
"command": "PARAMS=`echo -Itest ${relativeFile} -l ${lineNumber}`; echo $PARAMS > $TMPDIR/last_test_run; bundle exec ruby $PARAMS",
"group": "test",
"presentation": {
"reveal": "always",
"panel": "shared",
"clear": true
},
},
{
"label": "Run tests in current file",
"type": "shell",
"command": "PARAMS=`echo -Itest ${relativeFile}`; echo $PARAMS > $TMPDIR/last_test_run; bundle exec ruby $PARAMS",
"group": "test",
"presentation": {
"reveal": "always",
"panel": "shared",
"clear": true
},
},
{
"label": "Re-run last test",
"type": "shell",
"command": "bundle exec ruby `cat $TMPDIR/last_test_run`",
"group": "test",
"presentation": {
"reveal": "always",
"panel": "shared",
"clear": true
},
},
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment