QA CodeceptJS Writer
Purpose
Write CodeceptJS BDD/scenario-driven E2E tests from test case specifications. Transform structured test cases into executable scenarios using human-readable syntax (I.click, I.see, I.fillField), multi-backend support, and optional Gherkin BDD integration.
Trigger Phrases
- "Write CodeceptJS tests for [feature/flow]"
- "Generate CodeceptJS E2E tests from test cases"
- "Create CodeceptJS BDD scenarios for [flow]"
- "Add CodeceptJS tests with Gherkin for [feature]"
- "CodeceptJS scenario-driven tests for [page]"
- "CodeceptJS data-driven tests for [scenario]"
- "CodeceptJS Page Object for [page]"
- "CodeceptJS tests with Playwright/WebDriver/Puppeteer backend"
Workflow
- Read test cases — From qa-testcase-from-docs, qa-manual-test-designer, qa-browser-data-collector
- Generate scenarios — Create
Feature/Scenario blocks or .feature files
- Add step definitions — If BDD mode: implement Given/When/Then in step definition files
- Configure helper — Ensure
codecept.conf.ts has correct helper (Playwright, WebDriver, Puppeteer)
Key Features
| Feature |
Description |
| Scenario-driven syntax |
I.click, I.see, I.fillField, I.grabTextFrom — human-readable, framework-agnostic |
| Multi-backend |
Playwright, WebDriver, Puppeteer — switch via config without changing test code |
| BDD Gherkin |
.feature files + step definitions; Given/When/Then; Background, Examples, tables |
| Page Objects |
Encapsulate page logic; inject via inject() |
| Custom helpers |
Extend I with custom methods |
| Data-driven |
Data().Scenario for parameterized scenarios |
| within() |
Scope locators to a container element |
Test Types
| Type |
Scope |
Approach |
| Scenario |
E2E user flows |
Feature/Scenario blocks; I actor |
| BDD Gherkin |
Business-readable acceptance |
.feature files + step definitions |
| Data-driven |
Same flow, multiple data sets |
Data(table).Scenario with current |
Key Patterns
- Structure:
Feature('name') / Scenario('title', ({ I }) => { ... })
- Navigation:
I.amOnPage('/path')
- Interactions:
I.click('Submit'), I.fillField('Email', 'a@b.com'), I.selectOption('Country', 'US')
- Assertions:
I.see('Welcome'), I.seeElement('.user'), I.dontSee('Error')
- Scoped locators:
within('.modal', () => { I.click('OK'); })
- Data-driven:
Data(accounts).Scenario('Login', ({ I, current }) => { ... })
- Debugging:
pause() — interactive console during execution
- Auth:
autoLogin plugin — login once, reuse session
See references/patterns.md for full pattern reference.
BDD Mode (Gherkin)
- Feature files:
features/*.feature — human-readable scenarios
- Step definitions:
step_definitions/steps.ts — Given/When/Then implementations
- Init:
npx codeceptjs gherkin:init
- Snippets:
npx codeceptjs gherkin:snippets — generate stubs for undefined steps
- Run features only:
npx codeceptjs run --features
See references/patterns.md for Gherkin patterns.
Configuration
- codecept.conf.ts — helpers (Playwright/WebDriver/Puppeteer), plugins (autoLogin, allure), include (Page Objects), output
- Helper options — url, browser, restart, video, trace, storageState
See references/config.md for full configuration guide.
Context7 MCP
Uses Context7 MCP to fetch CodeceptJS documentation when needed. Query for CodeceptJS API, helpers, or configuration when patterns are unclear.
Scope
Can do (autonomous):
- Generate CodeceptJS scenario and BDD tests from test case specs
- Create Page Objects and inject them via
inject()
- Add
Data().Scenario for data-driven tests
- Configure
codecept.conf.ts (helpers, plugins, include)
- Use
within() for scoped interactions
- Add step definitions for Gherkin scenarios
- Use autoLogin plugin for auth
- Use Context7 MCP for CodeceptJS docs
Cannot do (requires confirmation):
- Change production code structure
- Add dependencies not in package.json
- Override project CodeceptJS config without approval
- Switch helper (Playwright ↔ WebDriver) without user preference
Will not do (out of scope):
- Execute tests (user runs
npx codeceptjs run)
- Write Jest/Vitest unit tests (use qa-jest-writer)
- Modify CI/CD pipelines
- Bypass security or access restricted areas
References
references/patterns.md — Scenario syntax, BDD Gherkin, Page Objects, custom helpers, data-driven
references/config.md — codecept.conf.ts, helpers, plugins, output
references/best-practices.md — Readable scenarios, step granularity, helper selection
Quality Checklist
Troubleshooting
| Symptom |
Likely Cause |
Fix |
| Element not found |
Locator too specific, dynamic content |
Use semantic locators (text, label); add data-test with customLocator |
| I is undefined |
Wrong inject/context |
Ensure ({ I }) => in Scenario; use inject() in step defs |
| Step definition not matched |
Regex/string mismatch |
Run gherkin:snippets; check Cucumber expressions |
| Backend-specific failure |
Helper API differs |
Playwright/WebDriver/Puppeteer have different methods; check helper docs |
| autoLogin not working |
Config or TypeScript |
Ensure plugin enabled; check login function export |
| Data().Scenario fails |
current not passed |
Use ({ I, current }); access current.columnName |
| within() scope wrong |
Nested structure |
Verify container selector; use strict locators { css: '...' } |
1---2name: qa-codeceptjs-writer3description: Generate CodeceptJS scenario-driven E2E and BDD tests for TypeScript with human-readable syntax, multi-backend support (Playwright/WebDriver/Puppeteer), and Gherkin integration.4---56# QA CodeceptJS Writer78## Purpose910Write CodeceptJS BDD/scenario-driven E2E tests from test case specifications. Transform structured test cases into executable scenarios using human-readable syntax (`I.click`, `I.see`, `I.fillField`), multi-backend support, and optional Gherkin BDD integration.1112## Trigger Phrases1314- "Write CodeceptJS tests for [feature/flow]"15- "Generate CodeceptJS E2E tests from test cases"16- "Create CodeceptJS BDD scenarios for [flow]"17- "Add CodeceptJS tests with Gherkin for [feature]"18- "CodeceptJS scenario-driven tests for [page]"19- "CodeceptJS data-driven tests for [scenario]"20- "CodeceptJS Page Object for [page]"21- "CodeceptJS tests with Playwright/WebDriver/Puppeteer backend"2223## Workflow24251. **Read test cases** — From qa-testcase-from-docs, qa-manual-test-designer, qa-browser-data-collector262. **Generate scenarios** — Create `Feature`/`Scenario` blocks or `.feature` files273. **Add step definitions** — If BDD mode: implement Given/When/Then in step definition files284. **Configure helper** — Ensure `codecept.conf.ts` has correct helper (Playwright, WebDriver, Puppeteer)2930## Key Features3132| Feature | Description |33|---------|-------------|34| **Scenario-driven syntax** | `I.click`, `I.see`, `I.fillField`, `I.grabTextFrom` — human-readable, framework-agnostic |35| **Multi-backend** | Playwright, WebDriver, Puppeteer — switch via config without changing test code |36| **BDD Gherkin** | `.feature` files + step definitions; Given/When/Then; Background, Examples, tables |37| **Page Objects** | Encapsulate page logic; inject via `inject()` |38| **Custom helpers** | Extend I with custom methods |39| **Data-driven** | `Data().Scenario` for parameterized scenarios |40| **within()** | Scope locators to a container element |4142## Test Types4344| Type | Scope | Approach |45|------|-------|----------|46| **Scenario** | E2E user flows | `Feature`/`Scenario` blocks; `I` actor |47| **BDD Gherkin** | Business-readable acceptance | `.feature` files + step definitions |48| **Data-driven** | Same flow, multiple data sets | `Data(table).Scenario` with `current` |4950## Key Patterns5152- **Structure:** `Feature('name')` / `Scenario('title', ({ I }) => { ... })`53- **Navigation:** `I.amOnPage('/path')`54- **Interactions:** `I.click('Submit')`, `I.fillField('Email', 'a@b.com')`, `I.selectOption('Country', 'US')`55- **Assertions:** `I.see('Welcome')`, `I.seeElement('.user')`, `I.dontSee('Error')`56- **Scoped locators:** `within('.modal', () => { I.click('OK'); })`57- **Data-driven:** `Data(accounts).Scenario('Login', ({ I, current }) => { ... })`58- **Debugging:** `pause()` — interactive console during execution59- **Auth:** `autoLogin` plugin — login once, reuse session6061See `references/patterns.md` for full pattern reference.6263## BDD Mode (Gherkin)6465- **Feature files:** `features/*.feature` — human-readable scenarios66- **Step definitions:** `step_definitions/steps.ts` — Given/When/Then implementations67- **Init:** `npx codeceptjs gherkin:init`68- **Snippets:** `npx codeceptjs gherkin:snippets` — generate stubs for undefined steps69- **Run features only:** `npx codeceptjs run --features`7071See `references/patterns.md` for Gherkin patterns.7273## Configuration7475- **codecept.conf.ts** — helpers (Playwright/WebDriver/Puppeteer), plugins (autoLogin, allure), include (Page Objects), output76- **Helper options** — url, browser, restart, video, trace, storageState7778See `references/config.md` for full configuration guide.7980## Context7 MCP8182Uses Context7 MCP to fetch CodeceptJS documentation when needed. Query for CodeceptJS API, helpers, or configuration when patterns are unclear.8384## Scope8586**Can do (autonomous):**87- Generate CodeceptJS scenario and BDD tests from test case specs88- Create Page Objects and inject them via `inject()`89- Add `Data().Scenario` for data-driven tests90- Configure `codecept.conf.ts` (helpers, plugins, include)91- Use `within()` for scoped interactions92- Add step definitions for Gherkin scenarios93- Use autoLogin plugin for auth94- Use Context7 MCP for CodeceptJS docs9596**Cannot do (requires confirmation):**97- Change production code structure98- Add dependencies not in package.json99- Override project CodeceptJS config without approval100- Switch helper (Playwright ↔ WebDriver) without user preference101102**Will not do (out of scope):**103- Execute tests (user runs `npx codeceptjs run`)104- Write Jest/Vitest unit tests (use qa-jest-writer)105- Modify CI/CD pipelines106- Bypass security or access restricted areas107108## References109110- `references/patterns.md` — Scenario syntax, BDD Gherkin, Page Objects, custom helpers, data-driven111- `references/config.md` — codecept.conf.ts, helpers, plugins, output112- `references/best-practices.md` — Readable scenarios, step granularity, helper selection113114## Quality Checklist115116- [ ] Human-readable steps; avoid raw CSS/XPath when semantic locators suffice117- [ ] Page Objects for page-specific logic; inject via `inject()`118- [ ] No hardcoded waits; use helper retry or explicit `I.waitForVisible`119- [ ] Tests independent; no shared state between scenarios120- [ ] BDD step definitions map to single, focused actions121- [ ] Data-driven tests use `Data().Scenario` with `current`122- [ ] Traceability to test case IDs where applicable123- [ ] No hardcoded secrets (use env vars)124125## Troubleshooting126127| Symptom | Likely Cause | Fix |128|---------|--------------|-----|129| Element not found | Locator too specific, dynamic content | Use semantic locators (text, label); add `data-test` with customLocator |130| I is undefined | Wrong inject/context | Ensure `({ I }) =>` in Scenario; use `inject()` in step defs |131| Step definition not matched | Regex/string mismatch | Run `gherkin:snippets`; check Cucumber expressions |132| Backend-specific failure | Helper API differs | Playwright/WebDriver/Puppeteer have different methods; check helper docs |133| autoLogin not working | Config or TypeScript | Ensure plugin enabled; check login function export |134| Data().Scenario fails | current not passed | Use `({ I, current })`; access `current.columnName` |135| within() scope wrong | Nested structure | Verify container selector; use strict locators `{ css: '...' }` |