Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rudyflores opened this issue May 3, 2024 · 6 comments
Open

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

rudyflores opened this issue May 3, 2024 · 6 comments
Assignees

Comments

@rudyflores
Copy link

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?

@connor4312 connor4312 self-assigned this May 6, 2024
@g-arjones
Copy link

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

@rudyflores
Copy link
Author

@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
Copy link

Yep. That does work indeed.

@wenytang-ms
Copy link

is there any update?

@rH4rtinger
Copy link

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

@kidtsunami
Copy link

I wonder if this is related to this line?

(report as any).exclude.relativePath = false;

That would jive with the workaround here #40 (comment)

For now if you fully qualify the paths in your coverage.exclude then they are properly excluded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants