Skip to content

Conversation

travzhang
Copy link
Contributor

@travzhang travzhang commented Jul 20, 2025

Summary

add istanbul coverage provider.

import { defineConfig } from '@rstest/core';

export default defineConfig({
  coverage: {
    enabled: true,
    provider: 'istanbul',
  },
});

Related Links

#398

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copy link

netlify bot commented Jul 20, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit be910c8
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/68c1507cef396c0008c2648e
😎 Deploy Preview https://deploy-preview-399--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@CLAassistant
Copy link

CLAassistant commented Jul 20, 2025

CLA assistant check
All committers have signed the CLA.

"pathe": "^2.0.3",
"std-env": "^3.9.0",
"swc-plugin-coverage-instrument": "^0.0.28",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builtin istanbul coverage directly into Rstest is too heavy. Rstest can provide a separate package for users to install as needed. When users set provider: 'istanbul', rstest can import the relevant transform plugin and provider from @rstest/coverage-istanbul.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@fi3ework fi3ework changed the title add istanbul coverage provider feat: add istanbul coverage provider Jul 22, 2025
@@ -221,6 +222,27 @@ export const prepareRsbuild = async (
...(config.module.parser.javascript || {}),
};

if (coverage?.enabled && coverage?.provider === 'istanbul') {
const swcPluginCoverageInstrument = `${process.cwd()}/node_modules/@rstest/coverage-istanbul/node_modules/swc-plugin-coverage-instrument/target/wasm32-wasip1/release/swc_plugin_coverage.wasm`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This path should be imported from @rstest/coverage-istanbul rather than hard-coded in rstset.

And target/wasm32-wasip1/release/swc_plugin_coverage.wasm is the default export of swc-plugin-coverage-instrument

image

config.module.rules ??= [];
config.module.rules.push({
test: /\.(js|ts)$/,
exclude: [/node_modules/],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some test files should be excluded.

@@ -0,0 +1,23 @@
import type { CoverageOptions } from '../types/coverage';
import type { CoverageProvider } from './istanbul';
import { IstanbulCoverageProvider } from './istanbul';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IstanbulCoverageProvider should also extract to @rstest/coverage-istanbul

@9aoy 9aoy requested a review from fi3ework September 10, 2025 10:59
@9aoy 9aoy merged commit 9b0bb2e into web-infra-dev:main Sep 11, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants