vscode-mocha-test-adapter icon indicating copy to clipboard operation
vscode-mocha-test-adapter copied to clipboard

nyc option

Open deleonio opened this issue 5 years ago • 9 comments

Can we combine mocha execution with coverage update?

deleonio avatar Apr 26 '19 21:04 deleonio

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.

anion155 avatar May 03 '19 17:05 anion155

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

frederikheld avatar Apr 20 '20 23:04 frederikheld

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.

hbenl avatar Jun 01 '20 16:06 hbenl

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.

deleonio avatar Jun 01 '20 17:06 deleonio

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 avatar Jun 02 '20 17:06 hbenl

@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 avatar Nov 20 '20 01:11 munierujp

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

hbenl avatar Jan 17 '21 15:01 hbenl

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

danielb2 avatar Apr 06 '22 20:04 danielb2

@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

shermr avatar Oct 25 '22 23:10 shermr