microsoft / vscode-test-cli

Command-line runner for VS Code tests
MIT License
19 stars 7 forks source link

Higher version than 0.0.4 will not work with exporting test coverage #24

Closed rH4rtinger closed 5 months ago

rH4rtinger commented 6 months ago

I had a problem, when I tried to export the coverage of my extension via c8.

I found out that the problem was the too new version of the @vscode/test-cli dependency.

Steps to reproduce

Setup the project

  1. Create a new project with yo code
  2. Install c8 for coverage npm install --save-dev c8
  3. Add in the package.json a coverage script:
    "scripts": {
    "vscode:prepublish": "npm run compile",
    "compile": "tsc -p ./",
    "watch": "tsc -watch -p ./",
    "pretest": "npm run compile && npm run lint",
    "lint": "eslint src --ext ts",
    "test": "vscode-test",
    "coverage": "c8 npm run test"
    }

I also added a sample method to my extension.ts:

export function add(a: number, b: number): number {
  return a + b;
}

I added a test for this method in my extension.test.ts:

suite("add", () => {
  test("should add 1 and 2", () => {
    assert.strictEqual(3, add(1, 2));
  });
});

Expected behavior

When I execute npm run coverage with the dependency "@vscode/test-cli": "^0.0.4", then everything works. I can see the coverage in my output. image

Actual behavior

When I execute npm run coverage with version of @vscode/test-cli set to 0.0.5 or 0.0.6, then my coverage is not visible image

leep-frog commented 5 months ago

I'm experiencing a similar issue except it doesn't work with any version. I also use c8 and tried different versions, but my coverage reports never produce the proper coverage info (coverage report shows all lines except class and function definitions as untested)

I'm also using esbuild to bundle my extension which might be relevant

connor4312 commented 5 months ago

Can you just run vscode-test --coverage without invoking c8?

rH4rtinger commented 5 months ago

I tested again with version 0.0.6. It works when I use vscode-test --coverage.

Can this be mentioned in the documentation ?

connor4312 commented 5 months ago

Yes, I have it on my plate this month to flesh out the documentation a lot more. Thanks for confirming the --coverage option works for you, I'll close this issue. Let us know if you have any other questions!