@currents/nx

中文文档
2.1.1发布于 2023/10/31MITTypeScriptCommonJS零依赖近 30 天下载 1.5万

Currents plugin for Nx

原始使用文档
文档目录10 节
  1. Example
  2. Setup
  3. Usage
  4. Configuration
  5. Setting the record key
  6. Setting the project id
  7. Migration
  8. Version 2.0.0
  9. Version 1.0.0
  10. Release

NX Plugin: Debug, troubleshoot and record Cypress CI tests in Cloud

NX plugin for running cypress tests using Currents or Sorry Cypress.

Integrate Cypress with alternative cloud services like Currents or Sorry Cypress.

The plugin is designed for CI environments and runs Cypress in headless mode. Please use @nx/cypress for running cypress in interactive mode.

Example

See ./apps/web-e2e for an example installation:

npx nx run web-e2e:currents --key <recordKey> --ci-build-id hello-currents-nx

Setup

Install npm dependencies:

npm i --save-dev @currents/nx cypress-cloud
# install cypress if needed
npm i --save-dev cypress

Add target currents to your project configuration:

{
  // ...
  "targets": {
    "currents": {
      "executor": "@currents/nx:currents",
      "options": {
        "record": true,
        "parallel": true,
        "cypressConfig": "apps/app-e2e/cypres.config.ts",
        // "key": "record key obtained from https://app.currents.dev"
        // "ciBuildId: "ci build id, read more at https://currents.dev/readme/guides/cypress-ci-build-id",
        // ... start a dev server if needed
        "devServerTarget": "my-react-app:serve",
        "testingType": "e2e"
      }
    }
  }
  // ...

Create a new configuration file: currents.config.js next to cypress.config.{jt}s

// currents.config.js
module.exports = {
  // Get the record key from https://app.currents.dev, can be any value for self-hosted instance of Sorry Cypress
  recordKey: 'XXX',
  // Set the `projectId` and the record key obtained from https://app.currents.dev or your self-hosted instance of Sorry Cypress
  projectId: 'Ij0RfK',
  // Sorry Cypress users - set the director service URL
  cloudServiceUrl: 'https://cy.currents.dev',
};

Add cypress-cloud/plugin to cypress.config.{js|ts|mjs}

import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';
import cloudPlugin from 'cypress-cloud/plugin';

export default defineConfig({
  e2e: {
    ...nxE2EPreset(__dirname, {
      bundler: 'vite',
    }),
    specPattern: './src/**/*.cy.ts',
    setupNodeEvents(on, config) {
      return cloudPlugin(on, config);
    },
  },
});

Usage

npx nx run web-e2e:currents --key <recordKey> --ci-build-id hello-currents-nx

Configuration

Options can be configured in project.json when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets.

See the schema.json for the list of available options. This plugin uses cypress-cloud for integrating cypress to 3rd party services. Please refer to cypress-cloud documentation for additional details.

Setting the record key

You can set the record key in one of the following ways:

  • set key property in project.json
  • set recordKey in currents.config.js
  • set the CLI flag --recordKey
  • set CURRENTS_RECORD_KEY environment variable

Setting the project id

You can set the project Id as follows:

  • set projectId in currents.config.js
  • set CURRENTS_PROJECT_ID environment variable

Migration

Version 2.0.0

Version 1.0.0

  • @nx/cypress no longer required - the plugin is a standalone implementation that is not dependent on @nx/cypress. Use the available configuration options to configure the execution of cypress runs.

Release

Create a new release (changelog, tags + github)

# run this command, review and stage the changelog
cd ./packages/nx && npm run release

Releasing beta channel:

npx nx publish nx --tag beta --otp CODE

Releasing latest channel:

npx nx publish nx --tag latest --otp CODE

版本与发布记录

@currents/nx 共发布 17 个版本,首次发布于 2021/11/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.1latest2023/10/313 年前
2.1.02023/10/293 年前
2.0.12023/04/123 年前
2.0.02023/04/053 年前
2.0.0-beta.02023/04/053 年前
1.0.0-beta.22023/01/103 年前

关于 @currents/nx 的常见问题

@currents/nx 是什么?

Currents plugin for Nx

如何安装 @currents/nx?

在项目目录运行 npm install @currents/nx,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@nx/devkit( >= 16)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@currents/nx 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@currents/nx 支持 ESM 还是 CommonJS?

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

@currents/nx 可以商用吗?

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

@currents/nx 的下载量有多少?

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

@currents/nx 还在维护吗?

最新版本 2.1.1 发布于 2023/10/31(3 年前);至今共发布 17 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/11/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。