microsoft / vscode-test-cli

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

Coverage file shows two test files #36

Closed leep-frog closed 4 months ago

leep-frog commented 4 months ago

Configuration

I have the following vscode test configuration:

// package.json
// ...
"scripts": {
    // ...
    "pretest": "npm run compile",
    "test": "vscode-test --coverage --coverageReporter lcov --coverageReporter html",
    "test-compile": "tsc -p ./",
  },
// .vscode-test.mjs

import { defineConfig } from '@vscode/test-cli';
import path from 'path';

export default defineConfig({
    files: 'out/test/**/*.test.js',
  useInstallation: {
    fromMachine: true,
    fromPath: path.resolve(".vscode-test", "vscode-win32-x64-archive-1.87.0", "Code.exe"),
  },
  workspaceFolder: path.resolve("src", "test", "test-workspace"),
  env: {
    VSCODE_STUBBABLE_TEST_FILE: stubbableTestFile,
  },
  mocha: {
    timeout: 60000,
  },
});

Actual Behavior

After running npm run test, the auto-generated coverage file (index.html) output file produces the following:

Note the duplicate lines for each file (aside from extension.ts)

image

Expected Behavior

I would expect there to only be one row per file. My best guess is that the coverage reporter tracks coverage on (1) files that are running locally (e.g. testing local methods) and (2) the same files that are running as part of the new VS Code window that is opened for the test execution.

I'm not actually testing any methods locally in this test suite, so it's mostly just coverage for function/variable declarations.

Would it be possible to either ignore the former type of coverage and/or to merge the coverage files?

connor4312 commented 4 months ago

Duplicates https://github.com/microsoft/vscode-test-cli/issues/49

leep-frog commented 4 months ago

Thanks for the redirect. I confirmed that this indeed was the issue by adding console.log(__filename) in one of my files and saw two outputs (note the casing of C:\):

C:\...\find.ts
c:\...\find.ts

so the issue you linked to is indeed the culprit. Just wanted to confirm for anyone else who stumbles upon this issue.

Thanks!