Running tests in VSCode

While we’re looking forward to the release of encore’s VS Code extension :smiley:, there is a simple trick to make tests runnable from the “Testing” pane using plain Go for VS Code extension.
As it is possible to set “Alternate Tools” for the Go extension and encore test has the same syntax as go test all you need is to create a simple script a script that passes the test command to encore and the rest to go binary:

#!/bin/sh

if [ $1 = 'test' ]
then
    encore $@
else
    go $@
fi

and use it in your settings.json:

"go.alternateTools": {
    "go": "~/encore-test-go-rest.sh"
}

Alas, I haven’t yet found the right hack to debug them, has anyone?

3 Likes