NX 插件: 在 Cloud 中调试、 排除和记录 Cypress CI 测试
无 运行 cypress 测试的插件 当前 或者说 对不起 Cypress。 。 。 .
将 Cypress 和 Cypress 等替代云服务融合在一起.
该插件是针对CI环境设计的,并以无头模式运行Cypress. 请使用 @nx/cypress 用于在交互式模式下运行cypress.
示例
见 ./应用程序/网络-e2e 例如,安装:
npx nx run web-e2e:currents --key <recordKey> --ci-build-id hello-currents-nx
设置
安装 npm 依赖性 :
npm i --save-dev @currents/nx cypress-cloud
# install cypress if needed
npm i --save-dev cypress
添加目标 currents 到您的工程配置 :
{
// ...
"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"
}
}
}
// ...
创建新配置文件 : currents.config.js 旁边 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',
};
添加 cypress-cloud/plugin 改为 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);
},
},
});
使用量
npx nx run web-e2e:currents --key <recordKey> --ci-build-id hello-currents-nx
- 更新您的
currents.config.js文件为projectId于 https://app.currents.dev (英语) - 使用在 https://app.currents.dev (英语)
配置
选项可以配置在 project.json 在定义执行者时,或者在引用时。 更多信息, 如何配置目标和执行者 : https://nx.dev/reference/project-confignation# 目标。 。 。 .
见 计划.json 的选项。 此插件使用 cypress-cloud 将 Cypress 整合到第三派对服务中 请参考 圆压-云层文档 其他细节.
设置记录密钥
您可以以下列方式设置记录密钥:
- 设定
key属性在project.json - 设定
recordKey内currents.config.js - 设置 CLI 旗
--recordKey - 设定
CURRENTS_RECORD_KEY环境变量
设置项目编号
您可以将工程编号设置如下:
- 设定
projectId内currents.config.js - 设定
CURRENTS_PROJECT_ID环境变量
移徙
版本 2.0.0
- 使用
cypress-cloud作为管弦乐工具
版本 1.0.0
@nx/cypress不再需要 - 插件是一个独立执行,不依赖于@nx/cypress。使用可用的配置选项配置 Cypress 运行的执行.
释放
创建新发布 (changelog, tags + github)
# run this command, review and stage the changelog
cd ./packages/nx && npm run release
释放β通道 :
npx nx publish nx --tag beta --otp CODE
发布最新频道 :
npx nx publish nx --tag latest --otp CODE