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

Coverage not generated when we are using babel with custom browser [locally] #2719

Open
skullpsg opened this issue Apr 28, 2024 · 0 comments

Comments

@skullpsg
Copy link

skullpsg commented Apr 28, 2024

I am trying to generate babel coverage report with istanbul format.Below is the config info of my project.

import { esbuildPlugin } from "@web/dev-server-esbuild";
import { defaultReporter } from "@web/test-runner";
import { junitReporter } from "@web/test-runner-junit-reporter";
import { playwrightLauncher } from "@web/test-runner-playwright";
import { fileURLToPath, URL } from "url";
import { fromRollup } from "@web/dev-server-rollup";
import rollupBabel from "@rollup/plugin-babel";

import resolveMimeType from "./mime-type-resolver.mjs";

const babel = fromRollup(rollupBabel);

export default {
  files: ["src/**/*.spec.ts", "src/**/*.spec.html"],
  plugins: [
    {
      name: "my-plugin",
      resolveMimeType(context) {
        return resolveMimeType(context.path);
      },
    },
    // Babel plugin
    babel({
      extensions: [".ts", ".tsx", ".js", ".jsx", ".es6", ".es", ".mjs"],
      include: ["src/**/*.ts", "src/**/*.js"],
      exclude: [
        "**/node_modules/**/*",
        "**/node_modules/.pnpm/**/*",
        "**/web_modules/**/*",
        "**/devserver_resources/**/*",
        "**/test_results/**/*",
        "**/__wds-outside-root__/**/*",
      ],
      babelHelpers: "bundled",
      presets: [["@babel/preset-env"], "@babel/preset-typescript"],
      plugins: [
        "babel-plugin-istanbul",
      ],
    }),
  ],
 browsers: [
   playwrightLauncher({
     launchOptions: {
      channel: "test",
       executablePath: <path-to-exe>,
     },
   }),
 ],
  staticLogging: !!process.env.CHROME_HEADLESS,
  reporters: [
    defaultReporter({
      reportTestResults: true,
      reportTestProgress: !process.env.CHROME_HEADLESS,
    }),
    junitReporter({
      outputPath: GetResultPath(),
      reportLogs: true,
    }),
  ],
  nodeResolve: {
    exportConditions: ["production"],
  },
  coverage: true,
  coverageConfig: {
    nativeInstrumentation: false,
    exclude: [
      "**/node_modules/**/*",
      "**/node_modules/.pnpm/**/*",
      "**/web_modules/**/*",
      "**/devserver_resources/**/*",
      "**/test_results/**/*",
      "**/*.spec.ts",
    ],
    report: true,
    reportDir: <coverage-path>,
    reporters: ["lcov", "json", "json-summary"],
  },
  playwright: true,
};

Above configuration generates empty result on coverage. If we remove be low configuration

 browsers: [
   playwrightLauncher({
     launchOptions: {
      channel: "test",
       executablePath: <path-to-exe>,
     },
   }),
 ],

It is generating result. How can we use browser with babel together to generate coverage result.

Thanks in advance.

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

1 participant