hbenl / vscode-mocha-test-adapter

Mocha Test Adapter for the VS Code Test Explorer
MIT License
90 stars 31 forks source link

nyc option #49

Open deleonio opened 5 years ago

deleonio commented 5 years ago

Can we combine mocha execution with coverage update?

anion155 commented 5 years ago

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.

frederikheld commented 4 years ago

@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 ;-)

hbenl commented 4 years ago

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.

deleonio commented 4 years ago

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.

hbenl commented 4 years ago

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.

munierujp commented 3 years ago

@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.

hbenl commented 3 years ago

@munierujp yes, that should work, but you'll have to use the absolute path to the script as the value for mochaExplorer.launcherScript.

danielb2 commented 2 years ago

I was hoping to be able to see statements not covered within vscode. I suppose this is not possible at this time then?

shermr commented 1 year ago

@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