How do I run the tests automatically in visual studio code. My project has testing setup, and the settings JSON/UI has settings related to auto running tests, but I don't see an option for the test to actually run automatically. I have found topics around this issue, but those seem to be out of date, or related to a (different) plugin.
CodePudding user response:
Since VSCode is a text editor rather than a fully-fledged IDE, tests are not a native feature. Testing frameworks also vary drastically between different programming languages or environments. I'd suggest looking into command-line tools such jest
for JavaScript which you can run via VSCode's integrated terminal.
Another approach is to create a custom task to run your test. Find an example for jest
here.
CodePudding user response:
The Python support for VSCode is an extension, which does not fully support "all" the testing features. The "Testing > Auto Run" settings are currently missing. This issue is being tracked here. https://github.com/microsoft/vscode-python/issues/19046
Until this feature is properly implemented, the best way to achieve this uses extensions such as "Run on Save", the most popular item in the marketplace. https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave
"emeraldwalk.runonsave": {
"commands": [
{
"match": "**.py",
"isAsync": true,
"cmd": "pytest"
}
]
}
(disclosure, I work for MSFT and was investigating this issue prior to finding the question while doing my own research on alternatives)