Background: I am experimenting with creating a vs code extension.
Context: I’ve started using the project you get from the yeoman scaffolding wizard ( e g npx --package yo --package generator-code -- yo code
and yo code
as per the getting started tutorial ).
The resulting hello world project ( I think this is the template src ) has a simple test that runs as integration tests in a VS code instance using vscode-test (src/test/extension.test.ts
).
(Incidentally, the resulting project is not the same as the vs code extension hello world sample.)
Need: I would like to create some fast running unit tests in this project, to be able to execute those unit tests naturally without running in an VS code instance. (say, unittests.test.ts
) So I need a configuration to execute certain unit tests, using just a test runner instead of using vscode-test.
In other words, the end result could be that the project (somehow) includes two test configurations: To run (a) tests that it can run as unit tests of the code (this question) – and not using vscode-test (?), and (b) (integration) tests that start up a separate test instance of vs code using vscode-test (which is what is included in the template to start with).
More context: Since the project uses mocha, I guess I just need to add some launch cfg for those tests. But I am not sure if it is possible or how to use that launch cfg for just some testfiles / tests?
What is there? The project has the basic vscode-test config in .vscode-test.mjs
, a config to run extension in .vscode/launch.json
and ofc package.json
defines the test script as vscode-test
.
Question!
Any ideas on:
- if and how I can add the configuration to run (1) some tests as “normal” unit tests (not in a test vs code instance) while keeping (2) the ability to run some tests as extension integration tests, starting a vs code test instance using vscode-test?
- What configurations do I need to add, to do it as as simple as possible using the template (the yeoman vs code extension template/scaffold result) as a starting point?
What I have tried!
Well, I have tried adding a new launch config (Mocha Tests) and making it active for debug – but that ofc did not have any effect since vscode-test is configured elsewhere, I think. Still vscode-test runs the tests… Is there a way to give VS code a config that runs (some) tests without vscode-test…?
Thanks for reading my question! BR!