This sets up the extension to run automated tests. The process is finicky but it works, and is ready for contributors to add tests. A sample test is included in extension.test.ts that runs through hg.status and hg.addAll commands.
Starts the VSCode sandbox version with the workspace set to the temp directory
Runs the test suite, which runs hg init on the temp dir.
Finicky, you say?
Well, yes. You need to quit VSCode for this to work or the npm command will complain, so if you want to edit code and run tests at the same time, edit the code in the VSCode Insiders Build.
The main limitation is that the tests can't be run from the launch bar. The launch.json config file is not expressive enough (AFAIK) to allow for a different temp directory to be used as the workspace each time. It bypasses runTest.ts completely and runs the test suite through an extension host that we don't have access to, so there is no way to run custom prep work (like creating a temp directory) before the VSCode sandbox is started.
This sets up the extension to run automated tests. The process is finicky but it works, and is ready for contributors to add tests. A sample test is included in
extension.test.ts
that runs throughhg.status
andhg.addAll
commands.The entry point for the tests is
runTest.ts
.Reference: https://code.visualstudio.com/api/working-with-extensions/testing-extension
How To Run
npm run test
.This does the following:
hg init
on the temp dir.Finicky, you say? Well, yes. You need to quit VSCode for this to work or the npm command will complain, so if you want to edit code and run tests at the same time, edit the code in the VSCode Insiders Build.
The main limitation is that the tests can't be run from the launch bar. The launch.json config file is not expressive enough (AFAIK) to allow for a different temp directory to be used as the workspace each time. It bypasses
runTest.ts
completely and runs the test suite through an extension host that we don't have access to, so there is no way to run custom prep work (like creating a temp directory) before the VSCode sandbox is started.