ns-e2e-tests
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate E2E Tests
创建E2E测试
Execution-phase Cypress implementation. Planning-phase: .
ns-spec-driven/references/e2e-test-task-generator.md执行阶段的Cypress实现。规划阶段参考:。
ns-spec-driven/references/e2e-test-task-generator.mdSession boot
会话启动
Load when present. See for layout and bootstrap summary.
.nextstage-harness/rules/e2e-tests-rules.mdcreferences/e2e-architecture.md若存在文件,请加载该文件。布局和初始化概要请参考。
.nextstage-harness/rules/e2e-tests-rules.mdcreferences/e2e-architecture.mdPhase 0 — Resolve or bootstrap Cypress root
阶段0 — 确定或初始化Cypress根目录
Before any spec or command code, locate the Cypress project or create it.
在编写任何测试用例或命令代码之前,先定位Cypress项目或创建新的Cypress项目。
0.1 — Detect existing E2E (brownfield)
0.1 — 检测已存在的E2E测试(遗留项目)
Search the repo in this order:
tests-e2e/cypress.config.ts- (legacy name)
testes-cypress/cypress.config.ts - (legacy co-located)
frontend/cypress.config.ts
Record the directory that contains as . All paths below are relative to unless noted.
cypress.config.ts{e2e_root}{e2e_root}按以下顺序搜索仓库:
tests-e2e/cypress.config.ts- (旧命名)
testes-cypress/cypress.config.ts - (旧的同目录存放方式)
frontend/cypress.config.ts
将包含的目录记录为****。除非特别说明,以下所有路径均相对于。
cypress.config.ts{e2e_root}{e2e_root}0.2 — Bootstrap when nothing exists (greenfield)
0.2 — 无匹配项时进行初始化(新项目)
If no match in 0.1, create as a standalone Node project:
tests-e2e/| Rule | Detail |
|---|---|
| Location | |
| Here — never add Cypress to |
| Tree | Per |
| |
| Scripts | |
Then set .
{e2e_root} = tests-e2e/Forbidden on greenfield: scaffolding under , copying deps into the frontend lockfile, or assuming Cypress is already installed in the app package.
frontend/cypress/如果在0.1中未找到匹配项,则创建**作为独立Node项目**:
tests-e2e/| 规则 | 详情 |
|---|---|
| 位置 | 仅限 |
| 在此文件中配置——切勿将Cypress添加至 |
| 目录结构 | 遵循 |
| |
| 脚本 | 在 |
然后设置。
{e2e_root} = tests-e2e/新项目禁用操作:在下搭建测试框架、将依赖复制到前端锁文件中、或假设应用包中已安装Cypress。
frontend/cypress/0.3 — Post-bootstrap documentation
0.3 — 初始化后文档更新
When or exists, add or update the E2E row: location , run command (or project docker equivalent).
docs/context/stack-confirmed.mdarchitecture-rules.mdtests-e2e/cd tests-e2e && npm run cypress:runDo not proceed to Phase 1 until is confirmed and is readable.
{e2e_root}cypress.config.ts若存在或文件,请添加或更新E2E相关条目:位置为,运行命令为(或项目对应的Docker命令)。
docs/context/stack-confirmed.mdarchitecture-rules.mdtests-e2e/cd tests-e2e && npm run cypress:run在确认存在且可读取之前,请勿进入阶段1。
{e2e_root}cypress.config.tsPhase 1 — Discovery (before feature code)
阶段1 — 调研(功能代码编写前)
- App under test — routes, forms, API usage, existing (read
data-testid, not write Cypress there)frontend/ - Existing commands — read all ; never duplicate
{e2e_root}/cypress/support/commands/ - Config — baseUrl, env vars (
{e2e_root}/cypress.config.ts,CYPRESS_BASE_URL)CYPRESS_API_URL
- 被测应用——路由、表单、API使用情况、已有的(仅读取
data-testid内容,请勿在此处编写Cypress代码)frontend/ - 已有命令——读取所有下的内容;禁止重复创建
{e2e_root}/cypress/support/commands/ - 配置——中的baseUrl、环境变量(
{e2e_root}/cypress.config.ts、CYPRESS_BASE_URL)CYPRESS_API_URL
Phase 2 — Command architecture first
阶段2 — 优先构建命令架构
{e2e_root}/cypress/support/commands/
shared/[feature].commands.ts # business actions — all devices
pages/[feature].commands.ts # page structure
device/mobile|tablet|desktop.commands.ts| Behavior | Location |
|---|---|
| Same on all devices | |
| Device-exclusive | |
| Page DOM structure | |
Register new command files in .
{e2e_root}/cypress/support/e2e.tsSpecs: /, , commands, assertions — no DOM logic in specs.
describeitcy.visit(){e2e_root}/cypress/support/commands/
shared/[feature].commands.ts # business actions — all devices
pages/[feature].commands.ts # page structure
device/mobile|tablet|desktop.commands.ts| 行为 | 位置 |
|---|---|
| 所有设备通用 | |
| 设备专属 | |
| 页面DOM结构 | |
在中注册新的命令文件。
{e2e_root}/cypress/support/e2e.ts测试用例:使用/、、自定义命令、断言——测试用例中禁止包含DOM逻辑。
describeitcy.visit()Phase 3 — Spec layout
阶段3 — 测试用例布局
{e2e_root}/cypress/e2e/device/
desktop/[feature]/[feature]-successful-flows.cy.ts
tablet/...
mobile/...Viewports in :
beforeEach- Desktop: 1280×720
- Tablet: 768×1024
- Mobile: 375×812
Forbidden: specs directly under without prefix.
cypress/e2e/device/{e2e_root}/cypress/e2e/device/
desktop/[feature]/[feature]-successful-flows.cy.ts
tablet/...
mobile/...在中设置视口:
beforeEach- 桌面端:1280×720
- 平板端:768×1024
- 移动端:375×812
禁止操作:测试用例直接放在下,不添加前缀。
cypress/e2e/device/Phase 4 — Implement
阶段4 — 实现
- Use from frontend task contract — do not invent
data-testid - No fixed — intercepts or assertion timeouts
cy.wait(N) - RBAC: menu hidden + direct URL denial
- Auth: login via UI or support session; tenant-aware fixtures
- 使用前端任务约定中的——禁止自行创建
data-testid - 禁止使用固定时长的——改用拦截或断言超时
cy.wait(N) - RBAC:菜单隐藏 + 直接URL访问拒绝
- 认证:通过UI或支持会话登录;支持多租户的测试数据
Phase 5 — Run and report
阶段5 — 运行与报告
From : (or docker equivalent documented for the product). Report failures with if needed.
{e2e_root}npm run cypress:runns-investigatorSDD version execution: when called under /
, write or refactor specs only — do not run the E2E
suite. The human runs E2E at version end.
execution-handoff.mdrun-implementation在目录下执行:(或产品文档中记录的Docker等效命令)。若测试失败,可使用进行排查。
{e2e_root}npm run cypress:runns-investigatorSDD版本执行说明:当在 / 下执行时,仅编写或重构测试用例——请勿运行E2E测试套件。测试套件将由相关人员在版本结束时运行。
execution-handoff.mdrun-implementationReferences
参考文档
| File | When |
|---|---|
| Root layout, bootstrap tree, rules |
| Task contract source |
| 文件 | 使用场景 |
|---|---|
| 根目录布局、初始化目录结构、规则 |
| 任务约定来源 |
Related skills
相关技能
ns-spec-driven— planning tasks with testid contractreferences/e2e-test-task-generator.md- — failing E2E debugging
ns-investigator - — CI
ns-gitlab-ci-generatorand change pathscd tests-e2e
ns-spec-driven—— 带testid约定的任务规划references/e2e-test-task-generator.md- —— 失败E2E测试调试
ns-investigator - —— CI中的
ns-gitlab-ci-generator命令及路径变更cd tests-e2e