Code coverage does not work with VS Code extension development
I am currently working on a VS Code extension in which I am using rewire for unit tests. The problem: Code that is executed only with rewire during unit tests is not detected as being covered by vscode-test.
I have set up a minimal example that demonstrates this (setup instructions are in the README): https://github.com/Pasu4/Rewire-Coverage-Example
I don't see how it would. Nor rewire, nor mocha collects any coverage info on its own. You need nyc/istanbul for this, or some other than mocha test runner able to collect coverage info from v8. I had no issues with collecting coverage with nyc from mocha + rewire from rewire'd code. Yet coverage was collected by nyc, not by mocha... Maybe some other runtime, like bun/deno, would collect coverage using embedded runner. Maybe even Node would, if you run it properly https://nodejs.org/en/learn/test-runner/collecting-code-coverage . In any case, mocha needs some help from external tools, and rewire has nothing to do with this
I don't see how it would. Nor rewire, nor mocha collects any coverage info on its own. You need
nyc/istanbulfor this, or some other thanmochatest runner able to collect coverage info from v8. I had no issues with collecting coverage withnycfrommocha + rewirefrom rewire'd code. Yet coverage was collected bynyc, not by mocha... Maybe some other runtime, like bun/deno, would collect coverage using embedded runner. Maybe even Node would, if you run it properly https://nodejs.org/en/learn/test-runner/collecting-code-coverage . In any case, mocha needs some help from external tools, and rewire has nothing to do with this
Mocha does have code coverage reporters, by default vscode-test sets Mocha to use the html code reporter. Though I can't imagine nyc/istanbul hurting to use instead if this isn't patchable.
Should probably clarify: it turns out vscode-test uses Istanbul (or some variant of it?) to report code coverage, sorry for the confusion. JS unit testing is pretty new to me as well 😅
That being said Mocha does also come with a couple built-in options? I'm not entirely sure from looking at their page.