refactoring-codeceptjs-tests
Refactoring CodeceptJS 4 Tests
Test suites rot in three predictable ways: duplicate UI flows copy-pasted across files, fat locators repeated everywhere, and raw JS escaping into Scenarios. The fix for each is moving the pattern to its proper home — page object, custom helper, or the auth plugin — without changing test behaviour.
This skill works targeted (refactor one test or file the user named) or global (sweep the whole tests directory). Either way it proposes changes first and applies after approval, in reviewable batches.
Workflow
1. Read the project (fundamentals)
Run the codeceptjs-fundamentals skill. You need: registered page objects (keys under include), the actor file (custom_steps.js or similar), any custom helpers already configured, and the auth plugin's user list. Without this you don't know where extractions land.
2. Pick scope
- Targeted — a file or Scenario the user named. Read it once, propose, apply.
- Global — the configured
testsglob. Treat as a multi-pass cycle: inventory → propose grouped → approve → apply a batch → re-run affected Scenarios → next batch. Never one big edit.