📝e2e-testing.md
AI-Powered E2E Testing: Shift-Left with Playwright CLI
AI-Powered E2E Testing: Shift-Left with Playwright CLI
Series Overview
This series is about fixing three very common testing failures in the right order.
- API coverage is written as giant bespoke specs instead of data-driven suites.
- Test setup is hidden in
beforeEachhooks and helper sprawl instead of being local and readable. - UI tests try to carry too much responsibility because the API layer was never made solid first.
The goal is not "use builders everywhere."
The goal is:
- direct API coverage for endpoint behavior
- fluent builders for setup and seeding
- short UI tests that focus on user workflows
The Working Model
Think about the stack in order, not as a buzzword diagram.
- Direct API tests cover create, read, update, delete, filtering, auth, boundaries, and negative cases.
- Builders sit on top of that coverage and create dependency graphs quickly.
- UI tests use those builders so setup stays out of the browser and out of
beforeEach.
One-line thesis:
Direct API tests prove behavior. Builders remove setup noise. Short UI tests prove the workflow.
Target Application
We use RealWorld (Conduit) because it has a stable API spec and a familiar set of domains:
- users and auth
- articles and tags
- comments
- profiles and follows
That keeps the examples realistic without tying the series to one product codebase.
Series Roadmap
| # | Article | Focus |
|---|---|---|
| 01 | Why We're Building a 2-Line E2E Testing Framework | The real problems to fix |
| 02 | Installing Playwright and Building Our Test Foundation | API-first Playwright setup |
| 03 | The Foundation: TestDefaults & TestDataHelper | Unique data and cleanup primitives |
| 04 | Stop Hand-Writing Giant API Specs | Data-driven direct API testing |
| 05 | Negative Cases, Boundary Coverage, and bugs.md | How to make failures useful |
| 06 | Builders as Seeding: Replace beforeEach Sprawl | Fluent setup for higher-level tests |
| 07 | One-Line Cleanup: The destroyWithAllDeps Pattern | Cleanup without hidden mess |
| 08 | Expanding Coverage: CommentBuilder & UserBuilder | More setup primitives |
| 09 | Page Components: Beyond Simple POM | UI structure |
| 10 | Fluent Form Builders: The FormBuilder Pattern | UI interaction layer |
| 11 | Inline Data Seeding: The .as() Method | Localize setup to the test |
| 12 | Putting It Together: 2-Line E2E Tests That Stay Honest | Short tests with clear intent |
| 13 | Maintaining 100% Coverage with AI Agents | Coverage tracking and maintenance |
The Directory Shape We Are Building Toward
automation/
src/
api/
domains/
content/
posts/
PostUtils.ts
PostValidations.ts
post.types.ts
index.ts
tests/
content/
posts/
PostTest.spec.ts
PostNegativeTest.spec.ts
Post.json
PostNegative.json
bugs.md
builders/
PostBuilder.ts
UserBuilder.ts
TestDataFactory.ts
pages/
components/
form-builders/The Shift
Old style:
- one huge API spec
- duplicated request code
- duplicated assertions
- setup hidden in hooks
- UI tests recreate everything through the browser
New style:
- scenario rows in JSON
- thin specs
- reusable validations
- local builder-based seeding
- UI tests that stay focused
Start with Why We're Building a 2-Line E2E Testing Framework ->