testeiya 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +312 -27
- package/dist/prompt/index.js +6 -2
- package/dist/prompt/index.js.map +1 -1
- package/dist/prompt/print.js +8 -0
- package/dist/prompt/print.js.map +1 -1
- package/dist/prompt/system-prompt.js +14 -4
- package/dist/prompt/system-prompt.js.map +1 -1
- package/dist/prompt/testomatio.js +3 -3
- package/dist/prompt/tools.js +15 -7
- package/dist/prompt/tools.js.map +1 -1
- package/dist/src/args.js +147 -47
- package/dist/src/args.js.map +1 -1
- package/dist/src/cli.js +50 -14
- package/dist/src/cli.js.map +1 -1
- package/dist/src/doctor.js +186 -0
- package/dist/src/doctor.js.map +1 -0
- package/dist/src/env.js +29 -5
- package/dist/src/env.js.map +1 -1
- package/dist/src/mcp.js +3 -3
- package/dist/src/mcp.js.map +1 -1
- package/dist/src/model.js +15 -10
- package/dist/src/model.js.map +1 -1
- package/dist/src/models.js +38 -0
- package/dist/src/models.js.map +1 -0
- package/dist/src/output.js +185 -0
- package/dist/src/output.js.map +1 -0
- package/dist/src/run.js +116 -24
- package/dist/src/run.js.map +1 -1
- package/dist/src/session.js +38 -23
- package/dist/src/session.js.map +1 -1
- package/dist/src/sessions.js +61 -0
- package/dist/src/sessions.js.map +1 -0
- package/package.json +7 -3
- package/prompt/index.ts +11 -2
- package/prompt/print.ts +9 -0
- package/prompt/system-prompt.ts +18 -4
- package/prompt/testomatio.ts +3 -3
- package/prompt/tools.ts +15 -7
- package/skills/codeceptjs/ci-fix-tests/SKILL.md +119 -0
- package/skills/codeceptjs/codeceptjs-auth/SKILL.md +141 -0
- package/skills/codeceptjs/codeceptjs-exploration/SKILL.md +100 -0
- package/skills/codeceptjs/codeceptjs-fundamentals/SKILL.md +196 -0
- package/skills/codeceptjs/codeceptjs-run-analysis/SKILL.md +83 -0
- package/skills/codeceptjs/debugging-codeceptjs-tests/SKILL.md +126 -0
- package/skills/codeceptjs/migrate-codeceptjs-4/SKILL.md +109 -0
- package/skills/codeceptjs/migrate-cypress-to-codeceptjs/SKILL.md +295 -0
- package/skills/codeceptjs/migrate-protractor-to-codeceptjs/SKILL.md +339 -0
- package/skills/codeceptjs/migrate-selenium-java-to-codeceptjs/SKILL.md +459 -0
- package/skills/codeceptjs/migrate-testcafe-to-codeceptjs/SKILL.md +338 -0
- package/skills/codeceptjs/refactoring-codeceptjs-tests/SKILL.md +78 -0
- package/skills/codeceptjs/writing-codeceptjs-tests/SKILL.md +102 -0
- package/skills/playwright/playwright-best-practices/SKILL.md +303 -0
- package/skills/playwright/playwright-best-practices/advanced/authentication-flows.md +360 -0
- package/skills/playwright/playwright-best-practices/advanced/authentication.md +871 -0
- package/skills/playwright/playwright-best-practices/advanced/clock-mocking.md +364 -0
- package/skills/playwright/playwright-best-practices/advanced/mobile-testing.md +409 -0
- package/skills/playwright/playwright-best-practices/advanced/multi-context.md +288 -0
- package/skills/playwright/playwright-best-practices/advanced/multi-user.md +393 -0
- package/skills/playwright/playwright-best-practices/advanced/network-advanced.md +452 -0
- package/skills/playwright/playwright-best-practices/advanced/third-party.md +464 -0
- package/skills/playwright/playwright-best-practices/architecture/pom-vs-fixtures.md +363 -0
- package/skills/playwright/playwright-best-practices/architecture/test-architecture.md +369 -0
- package/skills/playwright/playwright-best-practices/architecture/when-to-mock.md +383 -0
- package/skills/playwright/playwright-best-practices/browser-apis/browser-apis.md +391 -0
- package/skills/playwright/playwright-best-practices/browser-apis/iframes.md +403 -0
- package/skills/playwright/playwright-best-practices/browser-apis/service-workers.md +504 -0
- package/skills/playwright/playwright-best-practices/browser-apis/websockets.md +403 -0
- package/skills/playwright/playwright-best-practices/core/annotations.md +424 -0
- package/skills/playwright/playwright-best-practices/core/assertions-waiting.md +361 -0
- package/skills/playwright/playwright-best-practices/core/configuration.md +452 -0
- package/skills/playwright/playwright-best-practices/core/fixtures-hooks.md +417 -0
- package/skills/playwright/playwright-best-practices/core/global-setup.md +434 -0
- package/skills/playwright/playwright-best-practices/core/locators.md +242 -0
- package/skills/playwright/playwright-best-practices/core/page-object-model.md +315 -0
- package/skills/playwright/playwright-best-practices/core/projects-dependencies.md +453 -0
- package/skills/playwright/playwright-best-practices/core/test-data.md +492 -0
- package/skills/playwright/playwright-best-practices/core/test-suite-structure.md +361 -0
- package/skills/playwright/playwright-best-practices/core/test-tags.md +298 -0
- package/skills/playwright/playwright-best-practices/debugging/console-errors.md +420 -0
- package/skills/playwright/playwright-best-practices/debugging/debugging.md +504 -0
- package/skills/playwright/playwright-best-practices/debugging/error-testing.md +360 -0
- package/skills/playwright/playwright-best-practices/debugging/flaky-tests.md +496 -0
- package/skills/playwright/playwright-best-practices/frameworks/angular.md +530 -0
- package/skills/playwright/playwright-best-practices/frameworks/nextjs.md +469 -0
- package/skills/playwright/playwright-best-practices/frameworks/react.md +531 -0
- package/skills/playwright/playwright-best-practices/frameworks/vue.md +574 -0
- package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/ci-cd.md +468 -0
- package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/docker.md +283 -0
- package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/github-actions.md +546 -0
- package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/gitlab.md +397 -0
- package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/other-providers.md +521 -0
- package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/parallel-sharding.md +371 -0
- package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/performance.md +453 -0
- package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/reporting.md +424 -0
- package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/test-coverage.md +497 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/accessibility.md +359 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/api-testing.md +719 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/browser-extensions.md +506 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/canvas-webgl.md +493 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/component-testing.md +500 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/drag-drop.md +576 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/electron.md +509 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/file-operations.md +377 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/file-upload-download.md +562 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/forms-validation.md +561 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/graphql-testing.md +331 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/i18n.md +508 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/performance-testing.md +476 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/security-testing.md +430 -0
- package/skills/playwright/playwright-best-practices/testing-patterns/visual-regression.md +634 -0
- package/skills/playwright/playwright-cli/SKILL.md +420 -0
- package/skills/playwright/playwright-cli/references/element-attributes.md +23 -0
- package/skills/playwright/playwright-cli/references/playwright-tests.md +39 -0
- package/skills/playwright/playwright-cli/references/request-mocking.md +87 -0
- package/skills/playwright/playwright-cli/references/running-code.md +241 -0
- package/skills/playwright/playwright-cli/references/session-management.md +225 -0
- package/skills/playwright/playwright-cli/references/storage-state.md +275 -0
- package/skills/playwright/playwright-cli/references/test-generation.md +433 -0
- package/skills/playwright/playwright-cli/references/tracing.md +139 -0
- package/skills/playwright/playwright-cli/references/video-recording.md +143 -0
- package/skills/skills.lock.json +39 -36
- package/skills/testomatio/explorbot/explorbot-fundamentals/SKILL.md +76 -0
- package/skills/testomatio/explorbot/explorbot-fundamentals/references/no-install.md +36 -0
- package/skills/testomatio/explorbot/explorbot-plan/SKILL.md +108 -0
- package/skills/testomatio/explorbot/explorbot-setup/SKILL.md +86 -0
- package/skills/testomatio/qa-process/qa-explain-behavior/SKILL.md +111 -0
- package/skills/testomatio/qa-process/qa-explain-behavior/references/answer-shapes.md +116 -0
- package/skills/testomatio/qa-process/qa-explain-behavior/references/examples.md +157 -0
- package/skills/testomatio/qa-process/qa-lead-strategy-advisor/SKILL.md +91 -0
- package/skills/testomatio/qa-process/qa-lead-strategy-advisor/references/output-format.md +71 -0
- package/skills/testomatio/qa-process/testing-workflow/SKILL.md +227 -0
- package/skills/testomatio/test-automation/automate-manual-test-cases/CLAUDE.md +56 -0
- package/skills/testomatio/test-automation/automate-manual-test-cases/SKILL.md +242 -0
- package/skills/testomatio/test-automation/automate-manual-test-cases/references/CODECEPTJS_BEST_PRACTICES.md +182 -0
- package/skills/testomatio/test-automation/automate-manual-test-cases/references/FINAL_SUMMARY_TEMPLATE.md +22 -0
- package/skills/testomatio/test-automation/automate-manual-test-cases/references/PLAYWRIGHT_BEST_PRACTICES.md +90 -0
- package/skills/testomatio/test-automation/automate-manual-test-cases/references/POM_BEST_PRACTICES.md +53 -0
- package/skills/testomatio/test-automation/automate-manual-test-cases/references/TEST_DATA_MANAGEMENT.md +52 -0
- package/skills/testomatio/test-automation/debug-fix-failed-flaky-autotests/SKILL.md +107 -0
- package/skills/testomatio/test-automation/debug-fix-failed-flaky-autotests/references/DEBUGGING_QUICK_REFERENCE.md +113 -0
- package/skills/testomatio/test-automation/qa-automation-test-consolidation/SKILL.md +29 -0
- package/skills/testomatio/test-automation/qa-data-seeder/SKILL.md +83 -0
- package/skills/testomatio/test-automation/run-tests-with-testomatio-reporter/SKILL.md +153 -0
- package/skills/testomatio/test-automation/setup-change-aware-pr-testing/SKILL.md +190 -0
- package/skills/testomatio/test-automation/setup-ci-automation/SKILL.md +76 -0
- package/skills/testomatio/test-automation/testomat-allure-adapter/SKILL.md +289 -0
- package/skills/testomatio/test-management/detect-duplicate-test-cases/SKILL.md +86 -0
- package/skills/testomatio/test-management/detect-duplicate-test-cases/references/DUPLICATE_INSTRUCTIONS.md +54 -0
- package/skills/testomatio/test-management/improve-test-cases/SKILL.md +114 -0
- package/skills/testomatio/test-management/improve-test-cases/references/TESTOMAT_MARKDOWN_EXAMPLE.md +66 -0
- package/skills/testomatio/test-management/pull-request-diff-analyzer/SKILL.md +141 -0
- package/skills/testomatio/test-management/qa-e2e-tests-reporting/SKILL.md +354 -0
- package/skills/testomatio/test-management/qa-e2e-tests-reporting/references/TESTOMATIO_ARTIFACTS.md +82 -0
- package/skills/testomatio/test-management/qa-e2e-tests-reporting/references/TESTOMATIO_HTML_REPORT.md +37 -0
- package/skills/testomatio/test-management/qa-e2e-tests-reporting/references/TESTOMATIO_REPORTERS_CONFIG.md +118 -0
- package/skills/testomatio/test-management/qa-pr-requirements-analyzer/SKILL.md +149 -0
- package/skills/testomatio/test-management/qa-pr-requirements-analyzer/references/summary-example.md +54 -0
- package/skills/testomatio/test-management/qa-requirement-reviewer/SKILL.md +126 -0
- package/skills/testomatio/test-management/qa-requirement-reviewer/references/requirements_reviewer_examples.md +128 -0
- package/skills/testomatio/test-management/qa-split-testing-levels-pyramid/SKILL.md +55 -0
- package/skills/testomatio/test-management/qa-sprint-report-by-testomatio/SKILL.md +220 -0
- package/skills/testomatio/test-management/qa-sprint-report-by-testomatio/references/qa-sprint-report.md +126 -0
- package/skills/testomatio/test-management/qa-test-code-coverage/SKILL.md +174 -0
- package/skills/testomatio/test-management/qa-test-code-coverage/references/COVERAGE_FILE_FORMAT.md +138 -0
- package/skills/testomatio/test-management/qa-test-code-coverage/references/E2E_FRAMEWORKS.md +65 -0
- package/skills/testomatio/test-management/qa-test-code-coverage/scripts/check-coverage.mjs +40 -0
- package/skills/testomatio/test-management/qa-thinking/SKILL.md +36 -0
- package/skills/testomatio/test-management/qa-write-test-cases/SKILL.md +267 -0
- package/skills/testomatio/test-management/qa-write-test-cases/references/test-case-format.md +387 -0
- package/skills/testomatio/test-management/qa-write-test-cases/references/testomat-tms-guide.md +72 -0
- package/skills/testomatio/test-management/qa-write-test-cases/references/writing-rule.md +159 -0
- package/skills/testomatio/test-management/scan-automation-project/SKILL.md +152 -0
- package/skills/testomatio/test-management/sync-test-cases-with-tms/SKILL.md +107 -0
- package/skills/testomatio/test-management/sync-test-cases-with-tms/references/TESTOMATIO_CLI.md +140 -0
- package/skills/testomatio/test-management/testomatio-mcp/SKILL.md +195 -0
- package/skills/testomatio/test-management/testomatio-mcp/references/MCP_SETUP.md +177 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: migrate-codeceptjs-4
|
|
3
|
+
description: "Migrate a CodeceptJS 3.x project to 4.x. Trigger when `package.json` pins `codeceptjs` at 3.x or is missing `\"type\": \"module\"`, when test files still use CommonJS (`require()` / `module.exports`) against CodeceptJS APIs, when config references removed helpers (`Nightmare`, `Protractor`, `TestCafe`, `AI`, `SoftExpectHelper`, `Mochawesome`) or removed plugins (`autoLogin`, `tryTo`, `retryTo`, `eachElement`, `commentStep`, `fakerTransform`, `enhancedRetryFailedStep`, `allure`, `htmlReporter`, `wdio`, `selenoid`, `screenshotOnFail`, `pauseOnFail`, `stepByStepReport`), or when 3.x APIs are in use (`ai.request` function, Joi schemas in `seeResponseMatchesJsonSchema`, `restart: 'browser'`, `I.retry()`, `I.limitTime()`, Playwright `customLocators`)."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Migrate CodeceptJS 3.x → 4.x
|
|
7
|
+
|
|
8
|
+
CodeceptJS 4 is **ESM-only and TypeScript-first**. There is no compatibility shim for CommonJS — every helper, page object, custom step, and config file must be ESM. This skill drives a project through the upgrade end-to-end.
|
|
9
|
+
|
|
10
|
+
The authoritative reference is `node_modules/codeceptjs/docs/migration-4.md` (after `npm install codeceptjs@4`). Read it once; this skill orchestrates the work and surfaces the parts agents miss.
|
|
11
|
+
|
|
12
|
+
## When to trigger
|
|
13
|
+
|
|
14
|
+
Detect *before* acting. Look for any of:
|
|
15
|
+
|
|
16
|
+
- `package.json` lists `"codeceptjs": "^3"` / `"3.x"`, or has no `"type": "module"`.
|
|
17
|
+
- Tests, page objects, helpers, or config use `require()` / `module.exports` against CodeceptJS.
|
|
18
|
+
- Config still references removed helpers (`Nightmare`, `Protractor`, `TestCafe`, `AI`, `SoftExpectHelper`, `Mochawesome`) or removed plugins (`autoLogin`, `tryTo`, `retryTo`, `eachElement`, `commentStep`, `fakerTransform`, `enhancedRetryFailedStep`, `allure`, `htmlReporter`, `wdio`, `selenoid`, `screenshotOnFail`, `pauseOnFail`, `stepByStepReport`).
|
|
19
|
+
- 3.x APIs: `ai.request`, Joi schemas in `seeResponseMatchesJsonSchema`, `restart: 'browser'`, `I.retry()`, `I.limitTime()`, Playwright `customLocators`, `I.softExpect*` / `I.flushSoftAssertions`.
|
|
20
|
+
- `--reporter mochawesome` in scripts/CI, or `mochawesome` in `package.json` / `mocha.reporterOptions`.
|
|
21
|
+
|
|
22
|
+
If none of these hint at 3.x, the project is likely on 4.x already — hand back to `codeceptjs-fundamentals`.
|
|
23
|
+
|
|
24
|
+
## Workflow
|
|
25
|
+
|
|
26
|
+
Phases run in order. Commit at each boundary so any regression is bisectable.
|
|
27
|
+
|
|
28
|
+
### 1. Bump Node and CodeceptJS
|
|
29
|
+
|
|
30
|
+
- Confirm Node ≥ 16 (recommended 20+); update `engines.node` and CI runners.
|
|
31
|
+
- `npm install codeceptjs@4`.
|
|
32
|
+
- TypeScript projects: `npm install --save-dev tsx`. Replaces `ts-node/esm`, which now warns.
|
|
33
|
+
|
|
34
|
+
### 2. Convert the project to ESM
|
|
35
|
+
|
|
36
|
+
- Add `"type": "module"` to `package.json`. **Without this, every `.js` file parses as CommonJS and ESM imports throw at load time.**
|
|
37
|
+
- Convert config, page objects, custom helpers, custom steps, programmatic usage:
|
|
38
|
+
- `const Helper = require('@codeceptjs/helper')` → `import Helper from '@codeceptjs/helper'`
|
|
39
|
+
- `module.exports = X` → `export default X` (or named exports)
|
|
40
|
+
- `const { codecept, container, event } = require('codeceptjs')` → `import codeceptjs, { container, event } from 'codeceptjs'`
|
|
41
|
+
- `Container.create()` and `Config.load()` are now async — `await` them.
|
|
42
|
+
- Files that genuinely need CJS (rare; usually third-party shims): rename to `.cjs`.
|
|
43
|
+
|
|
44
|
+
### 3. Remove or replace deleted helpers and plugins
|
|
45
|
+
|
|
46
|
+
| Old | Replacement |
|
|
47
|
+
|---|---|
|
|
48
|
+
| Helper `Nightmare` / `Protractor` / `TestCafe` | `Playwright`, `Puppeteer`, or `WebDriver`. |
|
|
49
|
+
| Helper `AI` | Top-level `ai:` config + `aiTrace` plugin. |
|
|
50
|
+
| Helper `SoftExpectHelper` | `import { hopeThat } from 'codeceptjs/effects'`; call `hopeThat.noErrors()` at end of scenario. |
|
|
51
|
+
| Helper `Mochawesome` | **Stop and ask the user** — see "Mochawesome decision" below. Do not silently delete it. |
|
|
52
|
+
| Plugin `autoLogin` | `auth` plugin (see the `codeceptjs-auth` skill). |
|
|
53
|
+
| Plugin `tryTo` / `retryTo` | `import { tryTo, retryTo } from 'codeceptjs/effects'` |
|
|
54
|
+
| Plugin `eachElement` | `import { eachElement } from 'codeceptjs/els'` |
|
|
55
|
+
| Plugin `commentStep` | `import step from 'codeceptjs/steps'` → `step.section('name')` / `step.endSection()` |
|
|
56
|
+
| Plugin `fakerTransform` | `import { faker } from '@faker-js/faker'` directly in tests. |
|
|
57
|
+
| Plugin `enhancedRetryFailedStep` | Renamed to `retryFailedStep`. |
|
|
58
|
+
| Plugin `allure` / `htmlReporter` | `@testomatio/reporter` (HTML pipe). For JUnit XML, the `junitReporter` plugin. |
|
|
59
|
+
| Plugin `wdio` / `selenoid` | Configure via `helpers.WebDriver`, or run externally. |
|
|
60
|
+
| Plugin `screenshotOnFail` / `pauseOnFail` / `stepByStepReport` | Renamed `screenshot` / `pause` / `screenshot` with `slides: true`. Old names still resolve but emit a deprecation warning. |
|
|
61
|
+
|
|
62
|
+
#### Mochawesome decision
|
|
63
|
+
|
|
64
|
+
The bundled `Mochawesome` **helper** is removed in 4.x (the helper class, the `mochawesome` dependency, and the worker report-dir wiring). The `mochawesome` **reporter** itself still works — it is a stock Mocha reporter and never needed CodeceptJS to bundle it.
|
|
65
|
+
|
|
66
|
+
This is a **user choice — do not pick for them**. When you detect Mochawesome (the helper in `helpers:`, `--reporter mochawesome`, or `mochawesome` in `package.json`/`mocha.reporterOptions`), stop and ask which path they want:
|
|
67
|
+
|
|
68
|
+
1. **Switch to `@testomatio/reporter` (recommended).** Richer HTML report (steps, screenshots, videos, traces), worker-safe, no helper or internal coupling. `npm install --save-dev @testomatio/reporter`, enable the `testomatio` plugin, run with `TESTOMATIO_DISABLE_UPLOAD=1`. For JUnit XML add the `junitReporter` plugin. This is the path to recommend.
|
|
69
|
+
2. **Keep Mochawesome — report only.** Remove the `Mochawesome` helper from `helpers:`, keep `npm i -D mochawesome` and `--reporter mochawesome --reporter-options reportDir=output`. Loses the auto-embedded failure screenshots the helper provided.
|
|
70
|
+
3. **Keep Mochawesome — with embedded screenshots.** Remove the helper from `helpers:` and re-create it as a **project-local custom helper** that wraps `mochawesome/addContext` (a faithful port is in the migration guide, section "Keeping Mochawesome"). Flag the two caveats: it imports non-semver-stable `codeceptjs/lib/*` internals (pin the version), and the screenshot-plugin filename sync is no longer automatic (set `uniqueScreenshotNames` identically on the helper and the `screenshot` plugin).
|
|
71
|
+
|
|
72
|
+
In all cases also: remove `mochawesome` report-dir handling from any custom worker scripts, and replace any reliance on `I.addMochawesomeContext()` (only option 3 keeps it).
|
|
73
|
+
|
|
74
|
+
Present options 1–3 explicitly and let the user decide before changing anything. Default the recommendation to option 1. The full reference (before/after configs + the custom-helper port) is in `node_modules/codeceptjs/docs/migration-4.md` → "Mochawesome → Testomat.io Reporter".
|
|
75
|
+
|
|
76
|
+
### 4. Update changed APIs
|
|
77
|
+
|
|
78
|
+
- **AI config** — delete the `request` function. Install Vercel AI SDK + provider (`npm install ai @ai-sdk/openai`) and set `ai: { model: openai('gpt-5') }`. Same shape for `@ai-sdk/anthropic`, `@ai-sdk/google`, etc.
|
|
79
|
+
- **JSON schemas** — `I.seeResponseMatchesJsonSchema()` now uses Zod, not Joi. Rewrite (`Joi.object().keys({...})` → `z.object({...})`, `Joi.string().required()` → `z.string()`, etc.) and `npm uninstall joi`.
|
|
80
|
+
- **Playwright** — replace `restart: 'browser'` with `'session'` (default), `'context'`, or `'keep'`. Drop `customLocators` config; use the `customLocator` plugin or ARIA locators (`{ role: 'button', name: 'Submit' }`).
|
|
81
|
+
- **`I.retry()` / `I.limitTime()`** — **removed** (not just deprecated). Replace with the step options API: `import step from 'codeceptjs/steps'`, then pass the config as the **last argument** of the step. `I.retry(3).click('Submit')` → `I.click('Submit', step.retry(3))`; `I.limitTime(10).fillField('Email', x)` → `I.fillField('Email', x, step.timeout(10))`. Also `step.opts({ elementIndex: 2 })`. Behavior is unchanged except the option no longer leaks onto the following step. `recorder.retry()` is unaffected (custom helpers only).
|
|
82
|
+
- **`within` and `session`** — no longer global. `import { within, session } from 'codeceptjs'` (or `within` from `codeceptjs/effects`). Both return Promises — `await` when you need the return value.
|
|
83
|
+
- **Subpath imports** — `codeceptjs/effects`, `codeceptjs/els`, `codeceptjs/steps`, `codeceptjs/store`, `codeceptjs/assertions`. See the migration guide for the full list.
|
|
84
|
+
- **`tryTo` / `hopeThat`** — return `Promise<boolean>` (the 3.x `Promise<T | false>` shape is gone).
|
|
85
|
+
|
|
86
|
+
### 5. Adopt `noGlobals: true`
|
|
87
|
+
|
|
88
|
+
3.x leaked `Helper`, `actor`, `inject`, `share`, `secret`, `locate`, `dataTable`, `within`, `session`, `codecept_dir`, `output_dir` as globals. 4.x defaults `noGlobals: true` in new configs and warns for projects without it. Add it to config and replace globals with explicit imports from `codeceptjs` / `@codeceptjs/helper`. Test-runner globals (`Feature`, `Scenario`, `Before`, `After`, `BeforeSuite`, `AfterSuite`, `pause`, `inject`, `share`) and BDD step-definition globals (`Given`, `When`, `Then`, `And`) **stay** — they're scope-injected by the runner.
|
|
89
|
+
|
|
90
|
+
### 6. Bump dependent packages
|
|
91
|
+
|
|
92
|
+
If your project depends directly on these, verify nothing breaks: `chai` (4 → 6, ESM-only), `chai-as-promised` (7 → 8), `commander` (11 → 14), `@faker-js/faker` (9 → 10), `chokidar` (4 → 5), `@cucumber/gherkin` (35 → 38), `webdriverio` (9.12 → 9.23). `joi` and `testcafe` are removed. See migration guide §7 for the full table.
|
|
93
|
+
|
|
94
|
+
### 7. Verify
|
|
95
|
+
|
|
96
|
+
Run, in order:
|
|
97
|
+
|
|
98
|
+
1. `npx codeceptjs check -c <config>` — surfaces config / helper / plugin / page object issues without spinning up a browser.
|
|
99
|
+
2. `npx codeceptjs run --debug` on a small smoke scenario. Confirm steps execute and the report is sane.
|
|
100
|
+
3. `npx codeceptjs run-workers 2` — confirms the worker event dispatcher fires per-test events the same way it does in single-process mode (4.x change).
|
|
101
|
+
4. TypeScript users: confirm error stack traces point at `.ts` source lines (proves `tsx` is loaded, not `ts-node/esm`).
|
|
102
|
+
5. Grep the repo for `tryTo(`, `retryTo(`, `eachElement(`, `commentStep(`, `softExpect`, `I.softExpect`, `Joi.`, `restart: 'browser'`, `I.retry(`, `I.limitTime(`, and (unless the user chose to keep it) `Mochawesome` / `--reporter mochawesome` — none should remain. `step.retry(` / `step.timeout(` passed as a step argument is the expected replacement, not a leftover.
|
|
103
|
+
6. If the project used `autoLogin`: confirm the `auth` plugin restores sessions and roles.
|
|
104
|
+
|
|
105
|
+
## Related skills
|
|
106
|
+
|
|
107
|
+
- `codeceptjs-auth` — replacement for the removed `autoLogin` plugin
|
|
108
|
+
- `codeceptjs-fundamentals` — run **after** migration to confirm wiring
|
|
109
|
+
- Full reference: `node_modules/codeceptjs/docs/migration-4.md`
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: migrate-cypress-to-codeceptjs
|
|
3
|
+
description: "Port a Cypress test suite to CodeceptJS 4. Trigger when the project contains `cypress.config.{js,ts,mjs}`, a `cypress/` directory (`cypress/e2e/`, `cypress/support/{commands,e2e}.*`, `cypress/fixtures/`), `cypress` in `devDependencies`, or test code calling `cy.*` (`cy.visit`, `cy.get`, `cy.contains`, `cy.session`, `cy.intercept`, `cy.request`, `cy.task`, `cy.fixture`, `cy.origin`, `cy.mount`), `Cypress.Commands.add(...)`, or `Cypress.env(...)`."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Migrate Cypress → CodeceptJS 4
|
|
7
|
+
|
|
8
|
+
Cypress and CodeceptJS share a goal — browser end-to-end testing — but differ in three foundational ways:
|
|
9
|
+
|
|
10
|
+
1. **Step queueing vs command chains.** CodeceptJS auto-queues every `I.*` call onto an internal recorder; tests look synchronous and `await` is only needed for grabs (`await I.grabTextFrom(...)`). There is no `.then()` chain to thread state through.
|
|
11
|
+
2. **Helpers, not a bundled browser.** `I.*` dispatches to a configured helper. Cypress is single-browser by design; CodeceptJS lets you pick **Playwright** (recommended for Cypress migrators — Chromium parity plus cross-browser), Puppeteer, or WebDriver, and the test code stays the same.
|
|
12
|
+
3. **First-class abstractions.** Page objects, multi-user `session(...)`, the `auth` plugin, and custom helpers are built in. Cypress projects accumulate ad-hoc versions of these; the migration consolidates them onto the framework's idioms.
|
|
13
|
+
|
|
14
|
+
Authoritative reference: `node_modules/codeceptjs/docs/` (basics, locators, playwright, custom-helpers, pageobjects).
|
|
15
|
+
|
|
16
|
+
## When to trigger
|
|
17
|
+
|
|
18
|
+
Any of:
|
|
19
|
+
|
|
20
|
+
- `cypress.config.{js,ts,mjs}` at the repo root.
|
|
21
|
+
- A `cypress/` directory with `e2e/`, `support/`, `fixtures/`, `plugins/`, or `component/` subdirs.
|
|
22
|
+
- `cypress` listed in `devDependencies`.
|
|
23
|
+
- Test code calls `cy.*` (`cy.visit`, `cy.get`, `cy.contains`, `cy.session`, `cy.intercept`, `cy.request`, `cy.task`, `cy.fixture`, `cy.origin`, `cy.mount`), uses `Cypress.Commands.add(...)`, or reads `Cypress.env(...)`.
|
|
24
|
+
- The user says "migrate / port / convert from Cypress".
|
|
25
|
+
|
|
26
|
+
## What does not migrate
|
|
27
|
+
|
|
28
|
+
Be honest up-front:
|
|
29
|
+
|
|
30
|
+
- **Component tests** (`cy.mount`, `cypress/component/`) — CodeceptJS is E2E only. Keep Cypress for components, or move them to Playwright Component Testing / Vitest + Testing Library.
|
|
31
|
+
- **`cy.intercept('POST', '/api').as('save')` → `cy.wait('@save')`** — the closest equivalent is Playwright's `I.mockRoute()` (no alias, no `cy.wait('@x')`). Anchor waits on UI outcomes (`I.waitForText('Saved')`) instead of network events.
|
|
32
|
+
- **Cypress Cloud / time-travel debugger** — replaced by the `aiTrace` plugin's per-step artifacts and `@testomatio/reporter` for dashboards.
|
|
33
|
+
- **`cy.origin()` multi-origin flows** — limited support; document the gap and plan around it.
|
|
34
|
+
|
|
35
|
+
## Workflow
|
|
36
|
+
|
|
37
|
+
Run phases in order. Commit at each boundary so any regression is bisectable.
|
|
38
|
+
|
|
39
|
+
### 1. Inventory the Cypress project
|
|
40
|
+
|
|
41
|
+
Before touching anything, build a picture. Two passes.
|
|
42
|
+
|
|
43
|
+
**Shape of the project** — grep / `wc -l` for cost predictors:
|
|
44
|
+
|
|
45
|
+
- `cypress.config.{js,ts,mjs}` — which keys are in use
|
|
46
|
+
- `cypress/e2e/**/*.cy.{js,ts}` — spec count
|
|
47
|
+
- `cypress/fixtures/` — count + filenames
|
|
48
|
+
- `cypress/support/{e2e,commands}.{js,ts}` — these always exist; **read in full**
|
|
49
|
+
- `cypress/plugins/` — legacy preprocessor / task wiring
|
|
50
|
+
- `cypress/component/` + `cy.mount(` — flag for the user (out of scope)
|
|
51
|
+
- count occurrences of `cy.intercept(`, `cy.task(`, `cy.session(`, `cy.origin(`, `Cypress.Commands.add(`, `cy.fixture(` — each maps to a known replacement pattern
|
|
52
|
+
|
|
53
|
+
**Shared logic and shared locators** — Cypress has no built-in page objects, but suites accumulate shared abstractions anyway. Find them before touching test files:
|
|
54
|
+
|
|
55
|
+
- **Custom commands** — every `Cypress.Commands.add('<name>', fn)` in `cypress/support/commands.{js,ts}`. List name → arguments → body. Almost every suite has them (`cy.login`, `cy.seedData`, `cy.dragRowTo`, …).
|
|
56
|
+
- **Page-object-style modules** — look in `cypress/support/`, `cypress/pages/`, `cypress/page-objects/`, `cypress/helpers/`, `cypress/objects/`, `cypress/po/`, and any `pages/` / `pageObjects/` outside the cypress directory. Recognise: modules exporting selector bundles (`{ usernameField: '#user', submitBtn: '[data-cy=submit]' }`), modules exporting methods that call `cy.*` (`login(user, pwd)`, `goToProfile()`), classes with selectors as fields.
|
|
57
|
+
- **Shared selector constants** — files named `selectors.{js,ts}` / `locators.{js,ts}`, or modules exporting only strings. Grep specs for repeated `cy.get('[data-cy=...]')` strings — duplicates are abstraction candidates.
|
|
58
|
+
- **Utility helpers** — date formatters, URL builders, API wrappers (`api.js`, `helpers.js`, `utils.js`).
|
|
59
|
+
- **Global hooks** — `cypress/support/e2e.{js,ts}` `beforeEach` blocks, `Cypress.on('uncaught:exception', ...)`, etc.
|
|
60
|
+
|
|
61
|
+
Produce a short inventory: every shared abstraction with its current Cypress location and planned CodeceptJS destination (see phase 4's destination table). The user reviews before any code is written.
|
|
62
|
+
|
|
63
|
+
### 2. Install CodeceptJS alongside Cypress
|
|
64
|
+
|
|
65
|
+
`npx codeceptjs init` and pick the **Playwright** helper. Do not remove Cypress yet — both run in parallel through the migration, so a half-converted suite still has green coverage.
|
|
66
|
+
|
|
67
|
+
### 3. Port the config
|
|
68
|
+
|
|
69
|
+
Map `cypress.config.{js,ts}` keys → `codecept.conf.{js,ts}`:
|
|
70
|
+
|
|
71
|
+
| Cypress | CodeceptJS 4 (`Playwright` helper) |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `e2e.baseUrl` | `helpers.Playwright.url` |
|
|
74
|
+
| `viewportWidth` / `viewportHeight` | `helpers.Playwright.windowSize: '1280x720'` |
|
|
75
|
+
| `defaultCommandTimeout` | `helpers.Playwright.waitForTimeout` |
|
|
76
|
+
| `video` | `helpers.Playwright.video: true` |
|
|
77
|
+
| `screenshotOnRunFailure` | plugin `screenshot` with `on: 'fail'` |
|
|
78
|
+
| `retries` | top-level `retry: N` |
|
|
79
|
+
| `env.*` / `Cypress.env('X')` | `process.env.X` |
|
|
80
|
+
| `setupNodeEvents` / `cy.task` | custom helper or `bootstrap` / `teardown` |
|
|
81
|
+
|
|
82
|
+
### 4. Port shared abstractions
|
|
83
|
+
|
|
84
|
+
This is the bedrock. Do it before any spec rewrite — every spec rewrite shrinks because the verbs it needs (`I.doSmth(...)`) already exist.
|
|
85
|
+
|
|
86
|
+
**Hard rule for Cypress custom commands.** Every `Cypress.Commands.add('<name>', fn)` becomes a method on a custom helper. **Split commands across two helpers by the kind of operation** — they have different access patterns and different correct APIs:
|
|
87
|
+
|
|
88
|
+
- **`WebExtra`** (`lib/helpers/WebExtra.js`) for **browser-driven** commands — anything that needs the open page, DOM, `evaluate`, init scripts, storage, network-response waits. Reaches `this.helpers['Playwright'].page` / `.browserContext`.
|
|
89
|
+
- **`ApiExtras`** (`lib/helpers/ApiExtras.js`) for **pure HTTP** commands — programmatic login, seed/teardown data, CRUD against an API. Reaches `this.helpers['REST']` (or `GraphQL`). See `node_modules/codeceptjs/docs/api.md` for REST helper configuration.
|
|
90
|
+
|
|
91
|
+
One async method per Cypress command, named identically, so `cy.doSmth(arg)` → `I.doSmth(arg)`. Register both helpers under `helpers` in `codecept.conf.{js,ts}`.
|
|
92
|
+
|
|
93
|
+
**Never call `this.helpers['Playwright'].browserContext.request.*` for API work.** That bypasses the REST + `JSONResponse` stack — no step logging, no `I.seeResponseCodeIsSuccessful` assertions, no shared headers, and the same verb ends up split between helpers. If the API needs the same auth as the browser, share cookies once at the top of the config:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
import { setSharedCookies } from '@codeceptjs/configure'
|
|
97
|
+
setSharedCookies()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
…or set `defaultHeaders` on the REST helper for token-based auth, or use `I.amBearerAuthenticated(secret(token))` per test. All three patterns are covered in `api.md`.
|
|
101
|
+
|
|
102
|
+
**WebExtra example** — browser-driven commands (here `login` drives the UI form; the API-driven variant goes to `ApiExtras` below):
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
import Helper from '@codeceptjs/helper'
|
|
106
|
+
import fs from 'node:fs/promises'
|
|
107
|
+
|
|
108
|
+
export default class WebExtra extends Helper {
|
|
109
|
+
async login(user, password) {
|
|
110
|
+
const { page } = this.helpers['Playwright']
|
|
111
|
+
await page.goto('/login')
|
|
112
|
+
await page.getByLabel('Email').fill(user)
|
|
113
|
+
await page.getByLabel('Password').fill(password)
|
|
114
|
+
await page.getByRole('button', { name: 'Sign In' }).click()
|
|
115
|
+
await page.waitForURL(/\/dashboard/)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async setLocalStorage(key, value) {
|
|
119
|
+
const { page } = this.helpers['Playwright']
|
|
120
|
+
await page.evaluate(([k, v]) => localStorage.setItem(k, v), [key, value])
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async stubWindowOpen() {
|
|
124
|
+
const { page } = this.helpers['Playwright']
|
|
125
|
+
await page.addInitScript(() => {
|
|
126
|
+
window.__lastOpenUrl = null
|
|
127
|
+
const orig = window.open
|
|
128
|
+
window.open = (url, ...rest) => {
|
|
129
|
+
window.__lastOpenUrl = url
|
|
130
|
+
return orig ? orig.call(window, 'about:blank', ...rest) : null
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async writeJsonFile(filePath, data) {
|
|
136
|
+
await fs.writeFile(filePath, JSON.stringify(data, null, 2))
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**ApiExtras example** — pure HTTP commands routed through the REST helper:
|
|
142
|
+
|
|
143
|
+
```js
|
|
144
|
+
import Helper from '@codeceptjs/helper'
|
|
145
|
+
|
|
146
|
+
export default class ApiExtras extends Helper {
|
|
147
|
+
async loginViaApi(email, password) {
|
|
148
|
+
const REST = this.helpers['REST']
|
|
149
|
+
await REST.sendPostRequest('/login_ajax', { email, password, remember: false })
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async seedCourse(courseData) {
|
|
153
|
+
const REST = this.helpers['REST']
|
|
154
|
+
const { data } = await REST.sendPostRequest('/course', courseData)
|
|
155
|
+
return data
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Helper code style** — applies to both:
|
|
161
|
+
|
|
162
|
+
- All `import` statements at the **top of the file**. Never `const fs = await import('node:fs/promises')` inside a method.
|
|
163
|
+
- Use built-in assertions (`I.seeResponseCodeIsSuccessful` for API, `I.seeElement` for browser), `ExpectHelper`, or factories from `codeceptjs/assertions` — **never** `if (cond) throw new Error('...')`. Failures must render as proper assertion errors. See `node_modules/codeceptjs/docs/assertions.md`.
|
|
164
|
+
- If your `WebExtra` is growing a session-cache map keyed by user name, you are reimplementing the `auth` plugin — stop and let the `auth` plugin (phase 8) handle session reuse. The helper should expose `loginViaApi` / `login`; the plugin handles caching.
|
|
165
|
+
|
|
166
|
+
Cypress code that called `cy.window().then(...)`, `cy.wrap(...)`, or imperative DOM tricks translates cleanly into `page.evaluate(...)` inside `WebExtra`. Cypress code that called `cy.request(...)` translates to `REST.sendXxxRequest(...)` inside `ApiExtras`.
|
|
167
|
+
|
|
168
|
+
**Other destinations** from the phase 1 inventory:
|
|
169
|
+
|
|
170
|
+
- **Cypress page-object-style module** → CodeceptJS **page object class** under `pages/`. **Port conservatively** — keep only the methods the original module had; do not invent new wrappers during migration. Selector bundles become `this.fields = { ... }`; methods rewrite with `const { I } = inject()` at the top, calling `I.fillField`, `I.click`, and any `I.*` verb the `WebExtra` / `ApiExtras` helpers now contribute. Register under `include` in `codecept.conf.{js,ts}` so the page object auto-injects into Scenarios.
|
|
171
|
+
|
|
172
|
+
Page-object anti-patterns to avoid (unless the original Cypress code already had them):
|
|
173
|
+
- **Assertion methods** (`checkTitle() { I.seeElement(...) }`) — page objects are action verbs (`fillForm`, `submitOrder`); let assertions live in the test.
|
|
174
|
+
- **One-liner wrappers** around a single `I.click` / `I.see*` / `I.grabTextFrom` — the wrapper buys nothing over calling `I.*` from the test.
|
|
175
|
+
- **Methods used by only one test** — leave the steps in the test. Page objects exist for reuse.
|
|
176
|
+
- **`if (cond) throw new Error(...)`** in any method — use `I.see*`, `I.seeNumberOfElements`, `ExpectHelper`, or `codeceptjs/assertions` factories instead.
|
|
177
|
+
|
|
178
|
+
- **Shared selector constants** → fields on the relevant page object. No free-floating `selectors.js`.
|
|
179
|
+
- **Pure utility modules** that don't touch the browser → plain ES modules, imported where needed.
|
|
180
|
+
- **Global hooks** → CodeceptJS `Before` / `BeforeSuite` in tests, or `bootstrap` / `teardown` in config for one-off setup.
|
|
181
|
+
|
|
182
|
+
Sanity-check before moving on: `npx codeceptjs check -c <config>` must pass, and `npx codeceptjs list -c <config>` must show every Cypress command name as an `I.*` action contributed by `WebExtra` or `ApiExtras` — whichever owns it.
|
|
183
|
+
|
|
184
|
+
### 5. Convert spec files
|
|
185
|
+
|
|
186
|
+
One file at a time, leaning on the abstractions from phase 4. Hand off the per-spec work to the **`writing-codeceptjs-tests`** skill — it drives the live browser via MCP and verifies each step before committing.
|
|
187
|
+
|
|
188
|
+
| Cypress | CodeceptJS 4 |
|
|
189
|
+
|---|---|
|
|
190
|
+
| File `*.cy.{js,ts}` | `*_test.{js,ts}` |
|
|
191
|
+
| `describe('X', () => { ... })` | `Feature('X')` at top, one Feature per file |
|
|
192
|
+
| `it('Y', () => { ... })` | `Scenario('Y', ({ I }) => { ... })` |
|
|
193
|
+
| `beforeEach(() => { ... })` | `Before(({ I }) => { ... })` |
|
|
194
|
+
| `afterEach(() => { ... })` | `After(({ I }) => { ... })` |
|
|
195
|
+
| `before(...)` / `after(...)` | `BeforeSuite(...)` / `AfterSuite(...)` |
|
|
196
|
+
| `cy.visit('/x')` | `I.amOnPage('/x')` |
|
|
197
|
+
| `cy.login(u, p)` (custom command) | `I.login(u, p)` (from `WebExtra`) |
|
|
198
|
+
|
|
199
|
+
**Iteration** — in tests, page objects, and helpers, use **`for...of`** for any loop containing `I.*` calls. Never `Array.prototype.forEach`. `.forEach` swallows the iteration callback's return — an `await` inside it does not block the outer function, and the CodeceptJS recorder may queue steps out of order or finish the Scenario before the loop is done. `for...of` keeps the loop sequential and lets you add `await` later without rewriting:
|
|
200
|
+
|
|
201
|
+
```js
|
|
202
|
+
for (const sort of testSort) {
|
|
203
|
+
I.click(locate(this.filterFormLabel).withText(sort))
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
```js
|
|
208
|
+
for (const row of await I.grabWebElements('.row')) {
|
|
209
|
+
const text = await row.getText()
|
|
210
|
+
I.expectNotEmpty(text)
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Per batch**: `npx codeceptjs dry-run --steps -c <config>` — loads every Scenario, resolves every `I.*` call, no browser. Surfaces typos, missing imports, page objects not under `include`, and nonexistent verbs in seconds. Fix before anything real.
|
|
215
|
+
|
|
216
|
+
Then run the batch: `npx codeceptjs run --steps -c <config>`.
|
|
217
|
+
|
|
218
|
+
- First real runs almost always fail — locator drift, timing the source framework hid behind its own retry, auth/session differences, data assumptions. **Expected; fixing it is part of the migration.**
|
|
219
|
+
- Every failure → invoke `debugging-codeceptjs-tests` and fix on the fly (breakpoint, live-page inspection, verified fix). No blind rewrites, no `retry` masking.
|
|
220
|
+
- A batch is done when it runs green, not when it dry-runs clean.
|
|
221
|
+
|
|
222
|
+
### 6. Locators
|
|
223
|
+
|
|
224
|
+
**Scope every locator with a context.** The last argument of every action narrows the lookup to a region — `I.click('Save', '.toolbar')`, `I.fillField('Email', 'u@t.com', '#login-form')`, `I.click({ role: 'button', name: 'Delete' }, '.modal')`. A short semantic or ARIA locator plus a context beats one long unscoped locator: it reads like the page, disambiguates duplicate labels without growing, and survives markup churn. Apply this to every row of the tables below — the source framework's chain usually splits cleanly into *region* + *what the user sees*.
|
|
225
|
+
|
|
226
|
+
`cy.get(sel).within(() => ...)` and `cy.get(parent).find(child)` both collapse onto the context argument — that is where a Cypress chain's parent selector belongs.
|
|
227
|
+
|
|
228
|
+
CodeceptJS priority — pick the highest that fits, then add the context:
|
|
229
|
+
|
|
230
|
+
1. **Semantic strings** — button text, label, placeholder, link text: `I.click('Save', '.toolbar')`, `I.fillField('Email', 'u@t.com', '#login-form')`. Replaces most `cy.contains(...)` calls.
|
|
231
|
+
A plain string already matches `aria-label`, so an icon-only control with `aria-label="Save"` is `I.click('Save', <context>)` — never `'aria-label=Save'` or `{ css: '[aria-label="Save"]' }`.
|
|
232
|
+
2. **ARIA roles** — `I.click({ role: 'button', name: 'Sign In' }, '#login-form')`.
|
|
233
|
+
3. **`$name` via the `customLocator` plugin** — Cypress users often default to `[data-cy=...]`. Keep those attributes, but enable the plugin so they read as `I.click('$submit', '.checkout')` instead of `{ css: '[data-cy=submit]' }`.
|
|
234
|
+
4. **`locate()` builder** — `I.click(locate('button').withText('Edit').inside('tr').withText('Acme'))`; often better split as `I.click('Edit', locate('tr').withText('Acme'))`.
|
|
235
|
+
5. **CSS / XPath** — fallback only.
|
|
236
|
+
|
|
237
|
+
Full guidance in **`writing-codeceptjs-tests`** § Locators.
|
|
238
|
+
|
|
239
|
+
### 7. Actions, assertions, grabs
|
|
240
|
+
|
|
241
|
+
| Cypress | CodeceptJS 4 |
|
|
242
|
+
|---|---|
|
|
243
|
+
| `cy.get(sel).click()` | `I.click(sel)` |
|
|
244
|
+
| `cy.get(sel).type('x')` | `I.fillField(sel, 'x')` |
|
|
245
|
+
| `cy.get(sel).clear()` | `I.clearField(sel)` |
|
|
246
|
+
| `cy.get(sel).check()` / `.uncheck()` | `I.checkOption(sel)` / `I.uncheckOption(sel)` |
|
|
247
|
+
| `cy.get(sel).select('A')` | `I.selectOption(sel, 'A')` |
|
|
248
|
+
| `cy.get(sel).should('be.visible')` | `I.seeElement(sel)` |
|
|
249
|
+
| `cy.get(sel).should('have.text', 'X')` | `I.see('X', sel)` |
|
|
250
|
+
| `cy.get(sel).should('have.value', 'X')` | `I.seeInField(sel, 'X')` |
|
|
251
|
+
| `cy.get(sel).should('have.length', 5)` | `I.seeNumberOfElements(sel, 5)` |
|
|
252
|
+
| `cy.url().should('include', '/x')` | `I.seeInCurrentUrl('/x')` |
|
|
253
|
+
| `cy.get(sel).invoke('text').then(t => ...)` | `const t = await I.grabTextFrom(sel)` |
|
|
254
|
+
| `cy.getCookie('s')` | `const c = await I.grabCookie('s')` |
|
|
255
|
+
|
|
256
|
+
`await` only on grabs. Plain actions queue automatically.
|
|
257
|
+
|
|
258
|
+
### 8. Sessions and auth
|
|
259
|
+
|
|
260
|
+
`cy.session(id, setup, { validate })` and `cy.request`-based programmatic login → the **`auth` plugin**. Hand off to **`codeceptjs-auth`** for the setup walk-through. If phase 4 already ported `cy.login` into `WebExtra` as `I.login(...)`, the `auth` plugin's role definition just calls `I.login(...)`. For multi-user scenarios (Cypress has no native equivalent) use `session(...)` from `codeceptjs/effects`.
|
|
261
|
+
|
|
262
|
+
### 9. Fixtures, requests, tasks
|
|
263
|
+
|
|
264
|
+
| Cypress | CodeceptJS 4 |
|
|
265
|
+
|---|---|
|
|
266
|
+
| `cy.fixture('users.json')` | `import users from './fixtures/users.json' with { type: 'json' }` |
|
|
267
|
+
| `cy.request('POST', '/api/x', body)` | `await I.sendPostRequest('/api/x', body)` via the **REST helper**; for reusable flows wrap in the `ApiExtras` helper from phase 4 |
|
|
268
|
+
| `cy.task('seedDB')` | method on `ApiExtras` (if HTTP), a dedicated helper, or `bootstrap` / `teardown` |
|
|
269
|
+
|
|
270
|
+
REST helper auth: `setSharedCookies()` from `@codeceptjs/configure` shares the browser session with REST so the same user is logged in on both sides; alternatively set `defaultHeaders` for static tokens or `I.amBearerAuthenticated(secret(token))` per test. See `node_modules/codeceptjs/docs/api.md` for the full configuration surface, including `JSONResponse` assertions (`I.seeResponseCodeIsSuccessful`, `I.seeResponseContainsKeys`, `I.seeResponseMatchesJsonSchema` with Zod).
|
|
271
|
+
|
|
272
|
+
### 10. Network mocking
|
|
273
|
+
|
|
274
|
+
`cy.intercept(url, handler)` → `I.mockRoute(url, route => route.fulfill({ ... }))` (Playwright). Disable with `I.stopMockingRoute(url)`. There is no `cy.wait('@alias')` equivalent — anchor waits on UI outcomes (`I.waitForText`, `I.seeElement`) instead of network events.
|
|
275
|
+
|
|
276
|
+
### 11. Decommission Cypress
|
|
277
|
+
|
|
278
|
+
Only after every spec is ported and CI is green: delete `cypress/`, `cypress.config.*`, drop `cypress` from `devDependencies`, remove the Cypress CI jobs.
|
|
279
|
+
|
|
280
|
+
## Verify
|
|
281
|
+
|
|
282
|
+
1. `npx codeceptjs check -c <config>` — config + helper + plugin sanity.
|
|
283
|
+
2. `npx codeceptjs list -c <config>` — every ported Cypress command appears as an `I.*` action from `WebExtra` or `ApiExtras`; every page object's methods appear.
|
|
284
|
+
3. `npx codeceptjs dry-run --steps -c <config>` — every Scenario loads.
|
|
285
|
+
4. Full run: `npx codeceptjs run --steps -c <config>`. Failures are expected on first runs — drive each to a fix via the **`debugging-codeceptjs-tests`** skill (not `retry`, not blind rewrites). The migration is complete only when the whole converted suite is green.
|
|
286
|
+
5. Hand off to **`codeceptjs-run-analysis`** to inspect `output/trace_*/` artifacts (requires the `aiTrace` plugin enabled).
|
|
287
|
+
6. `grep -r "cy\." cypress/` — empty before deleting `cypress/`.
|
|
288
|
+
|
|
289
|
+
## Related skills
|
|
290
|
+
|
|
291
|
+
- `writing-codeceptjs-tests` — per-spec rewrite playbook (MCP-driven, verified steps)
|
|
292
|
+
- `debugging-codeceptjs-tests` — use on every failing test from the first full run
|
|
293
|
+
- `codeceptjs-auth` — replaces `cy.session()` and programmatic login
|
|
294
|
+
- `codeceptjs-fundamentals` — run after migration to confirm wiring
|
|
295
|
+
- Reference docs: `node_modules/codeceptjs/docs/` (basics, playwright, locators, custom-helpers, api, assertions, pageobjects, data, sessions, effects)
|