Skip to content

框架与工具 ​

按用途查找集成:浏览器测试、Vitest 与 Jest、TypeScript或 VS Code。没有现成方案时,参见通用接入方式。

Playwright ​

覆盖率采集代码参见 使用 Playwright 采集 V8 覆盖率。

Puppeteer ​

覆盖率采集代码参见 使用 Puppeteer 采集 V8 覆盖率。

Vitest ​

Jest ​

Cypress ​

WebdriverIO ​

Storybook Test Runner ​

Selenium Webdriver ​

CodeceptJS ​

TestCafe ​

TypeScript ​

在 Node.js 22.18.0 或更高版本上,推荐使用内置的类型擦除直接运行只含可擦除语法的 TypeScript,无需构建步骤或外部 loader。

sh
npx mcr node ./src/example.ts
npx mcr test "./test/**/*.test.ts"

配置和覆盖率行为参见 TypeScript 支持。tsx 和 ts-node 示例参见外部加载器。

VSCode ​

Node.js 覆盖率 Reporter ​

推荐直接使用 mcr test,无需单独配置覆盖率 reporter,参见使用 mcr test 运行测试。

c8 ​

  • c8 从 v10.1.0 起以实验功能集成 MCR。
sh
c8 --experimental-monocart --reporter=v8 --reporter=console-details node foo.js

如果使用 Node.js 内置测试运行器,推荐使用 mcr test 代替独立的覆盖率采集流程,参见使用 mcr test 运行测试。

Mocha ​

sh
mcr mocha ./test/**/*.js

对于 Node.js 单元测试和集成测试,推荐使用 mcr test 代替,参见使用 mcr test 运行测试。

AVA ​

sh
mcr ava

对于 Node.js 单元测试和集成测试,推荐使用 mcr test 代替,参见使用 mcr test 运行测试。


注:使用 mcr test 替代测试运行器,是指迁移到 node:test,并非只替换命令;原框架的测试 API、断言和钩子可能需要调整。