@cypress/instrument-cra

中文文档
1.4.0发布于 2020/10/27MITCommonJS近 30 天下载 8.2万

Little module for CRA applications to instrument code without ejecting react-scripts

此软件包已被标记为弃用

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

原始使用文档
文档目录10 节
  1. Install and use
  2. Exclude files
  3. Instrument a fork
  4. Force instrumentation
  5. Debugging
  6. Notes
  7. Examples
  8. In this repository
  9. External
  10. License

@cypress/instrument-cra renovate-app badge CircleCI

Little module for CRA applications to instrument code without ejecting react-scripts

Install and use

yarn add @cypress/instrument-cra

Then change your npm start script to require this module before starting the dev server

{
  "scripts": {
    "start": "react-scripts -r @cypress/instrument-cra start",
  }
}

This module assumes standard Create-React-App v3 JavaScript application with source files in the "src" folder.

When the app starts with yarn start, you should see the coverage information under window.__coverage__ information.

Coverage object

The instrumentation is done using Istanbul.js via babel-plugin-istanbul and is compatible with @cypress/code-coverage plugin.

Exclude files

If you want to exclude files from coverage, for example src/serviceWorker.js, add an object named nyc to package.json following the nyc CLI configuration.

{
  "nyc": {
    "exclude": "src/serviceWorker.js"
  }
}

Instrument a fork

To instrument a fork of react-scripts, provide the path to the new webpack.config.js in your package.json as cypressWebpackConfigPath, e.g.:

{
  "cypressWebpackConfigPath": "./node_modules/@my-org/my-react-scripts-fork/config/webpack.config.js"
}

Force instrumentation

Usually, the code is only instrumented in the development environment. If you want to force the instrumentation, set the environment variable

CYPRESS_INSTRUMENT_PRODUCTION=true

Debugging

Run with environment variable DEBUG=instrument-cra to see the verbose logs

Notes

If you try to start the application, and react-scripts shows an error There might be a problem with the project dependency tree., just create a local file .env with. The problem is due to several versions of babel-loader dependency between this plugin and your application.

SKIP_PREFLIGHT_CHECK=true

Examples

In this repository

External

License

MIT License, see LICENSE

版本与发布记录

@cypress/instrument-cra 共发布 8 个版本,首次发布于 2019/08/09;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.4.0latest2020/10/276 年前
1.3.22020/09/196 年前
1.3.12020/07/236 年前
1.3.02020/07/236 年前
1.2.02020/07/236 年前
1.1.12020/04/216 年前

关于 @cypress/instrument-cra 的常见问题

@cypress/instrument-cra 是什么?

Little module for CRA applications to instrument code without ejecting react-scripts注意:该包已被作者标记为弃用——Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

如何安装 @cypress/instrument-cra?

在项目目录运行 npm install @cypress/instrument-cra,或使用 pnpm add / yarn add / bun add。

@cypress/instrument-cra 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cypress__instrument-cra 是否存在。

@cypress/instrument-cra 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@cypress/instrument-cra 可以商用吗?

@cypress/instrument-cra 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cypress/instrument-cra 的下载量有多少?

根据 npm 官方下载统计,@cypress/instrument-cra 在 2026/10/11 – 2026/11/09 这 30 天内被下载 82,012 次,日均约 2,734 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cypress/instrument-cra 还在维护吗?

最新版本 1.4.0 发布于 2020/10/27(6 年前);至今共发布 8 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/08/09。作者已将其标记为弃用,新项目建议寻找替代方案。