I just lost way too many hours of my life figuring out how to run the command test-explorer.run-all
defined by this plugin. If you substitute editor.codeActionsOnSave
for test-explorer.run-all
everywhere below I think that should work.
What I've hacked together is to first of all install the Trigger Task on Save extension
which, instead of bash commands as per the other answer, runs VS code tasks on save.
As per the VS code docs
you can then define a custom task to wrap the command. For me, this looks like
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "mocha-explorer",
"command": "${command:test-explorer.run-all}",
}
]
}
Here mocha-explorer
is my own arbitrary label for this.
Finally, configure the settings.json
file to run your task on save by its label, which for me looks like:
"triggerTaskOnSave.tasks": {
"mocha-explorer": ["*.js"]
}
I'm a total newb to all this VS code config but I hope that helps someone.
A related useful answer that may be helpful for more complex tasks: Is there a way to run a command with VS Code tasks?