vscode-mocha-test-adapter
vscode-mocha-test-adapter copied to clipboard
nyc option
Can we combine mocha execution with coverage update?
You can wrap mocha module with nyc. This one did worked for me: https://gist.github.com/anion155/22147ed41655d67c8d69e0d164a6fe2d. Don't forget to set the mochaExplorer.mochaPath
to module file.
@hbenl Your's is the only mocha test runner extension for VSCode that runs flawlessly out of the box and with the features I would expect such a plugin to have. Thanks for your great work!
I would highly appreciate if it would generate Istanbul coverage reports out of the box as well. There are a couple of extensions that integrate coverage information into VSCode from existing coverage reports. So as a first step just running nyc
when the tests are run would be enough. But with the highlighting part integrated, your extension would be the one-stop-shop for all my testing needs and I could finally stop fiddling around with a truckload of extensions ;-)
I have finally figured out how to do this and created a launcher script. To use it, add the launcher scripts to your project:
npm install --save-dev mocha-explorer-launcher-scripts
Then add the following to your VS Code settings:
"mochaExplorer.launcherScript": "node_modules/mocha-explorer-launcher-scripts/nyc"
I'll add some documentation about the options later, but it should work without any additional configuration.
Hi @hbenl, thank you, but that is not a out-of-the-box solution. It is a additional dependency and brings a additional risk to the tool chain.
The better way would be a additonal option inside the test explorer extension.
that is not a out-of-the-box solution.
Obviously.
If there is enough interest, I will integrate it properly. But it works for now, is a good example for the versatility of the launcher script mechanism and users can easily modify it for their projects if that should be necessary.
I also hope to get some feedback if this is working as expected for nyc
users - especially since I don't have much experience with nyc
myself.
@hbenl Can I install mocha-explorer-launcher-scripts
globally and use it from this extension? I don't want to add an environment-dependent package to package.json
.
@munierujp yes, that should work, but you'll have to use the absolute path to the script as the value for mochaExplorer.launcherScript
.
I was hoping to be able to see statements not covered within vscode. I suppose this is not possible at this time then?
@danielb2 you may have already figured this out, but for anyone else seeing this issue there is an excellent extension called coverage gutters that will read and show coverage