microsoft / vscode-test-cli

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

`vscode-test-cli` not excluding files from coverage report #40

Open rudyflores opened 2 months ago

rudyflores commented 2 months ago

I have the following configuration file:

/** @type {import('@vscode/test-cli').IConfigurationWithGlobalOptions} */
export default defineConfig({
  /** @type {import('@vscode/test-cli').TestConfiguration[]} */
  tests: [
    {
      files: [
        `__tests__/__integration__/out/__tests__/__integration__/**/*.test.js`,
      ],
      version: "stable",
      extensionDevelopmentPath: __dirname,
      workspaceFolder: `${__dirname}/__tests__/__integration__/resources`,
      srcDir: "./src",
    },
  ],
  /** @type {import('@vscode/test-cli').ICoverageConfiguration} */
  coverage: {
    includeAll: true,
    reporter: ["lcov", "text-summary"],
    output: `${__dirname}/__tests__/__results__/integration`,
    exclude: ["**/node_modules/**"],
  },
});

And I am unable to generate a coverage report that excludes my node_modules event though I specifically mention to exclude those in coverage.exclude any idea if i'm missing something in my configuration?

g-arjones commented 1 month ago

I am experiencing the same behavior. Files are not excluded from coverage report (they are when c8 is called from command line instead)

rudyflores commented 1 month ago

@g-arjones I found doing this produced a better coverage report! But I wish there was a simpler way to have this setup since it still doesn't provide all the proper files:

import { defineConfig } from "@vscode/test-cli";
import { fileURLToPath } from "url";
import { dirname } from "path";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

/** @type {import('@vscode/test-cli').IConfigurationWithGlobalOptions} */
export default defineConfig({
  /** @type {import('@vscode/test-cli').TestConfiguration[]} */
  tests: [
    {
      files: "./__tests__/__integration__/out/**/*.test.js",
      version: "stable",
      extensionDevelopmentPath: __dirname,
      workspaceFolder: `${__dirname}/__tests__/__integration__/resources`,
      srcDir: "./__tests__/__integration__/out/src",
      mocha: {
        timeout: 5000,
      },
    },
  ],
  coverage: {
    exclude: [
      `${__dirname}/out`,
      `${__dirname}/__tests__/__integration__/out/__tests__`,
    ],
  },
});
g-arjones commented 1 month ago

Yep. That does work indeed.

wenytang-ms commented 1 month ago

is there any update?

rH4rtinger commented 2 days ago

Any update on this?

I have a extension that is packed with webpack and it gives me the dist folder in my coverage, even if I try to exclude the folder via any of the following dist patterns

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

export default defineConfig({
  files: ["out/test/suite/**/*.test.js"],
  version: "insiders",
  workspaceFolder: "./out/temp/workspace",
  launchArgs: ["--disable-extensions", "--profile-temp"],
  coverage: {
    exclude: ["dist", "**/dist/**", /dist/],
  },
});

used vscode-test-cli version: 0.0.10