To simplify update of test snapshots generated by https://github.com/allaboutapps/go-starter/blob/master/internal/test/helper_snapshot.go
Updates all snapshots in a test file or a package. Runs tests with TEST_UPDATE_GOLDEN=true. Then runs the tests again without updating the snapshots.
-
Clone this repo locally, preferrably within your VS Code Project.
-
Instal VS Code Command Runner: https://marketplace.visualstudio.com/items?itemName=edonet.vscode-command-runner
-
Go to Settings and search for Command-Runner:Commands, click on "Edit in settings.json".
Paste the command settings:
"command-runner.commands": {
"Update file snapshots": "python3 SCRIPT_LOCATION -P ${workspaceFolder} -pkg ${fileDirname} -f ${file}",
"Update package snapshots": "python3 SCRIPT_LOCATION -P ${workspaceFolder} -pkg ${fileDirname}",
},
Replace SCRIPT_LOCATION with the absolute path of the main.py script.
Open any go test file and press Crtl+Shift+R.
You will see the list of commands to run.
Just select one of them and observe the magic.
Congratulations, you saved 5s of your life not doing it manually! 🥳