From first
cy.visitto a green Module G Cypress suite β competition-ready frontend testing.
Powered by Marketable IT Skills (MITS) initiative
This course teaches Cypress end-to-end testing by implementing the full rider-UI suite from the Skill IT Training Camp 2026 competition outline Module G β SwapLoop Automated Testing (Part A β Frontend testing with Cypress). You work against the provided SwapLoop multi-page app and do not change application source β you fill Cypress it bodies under cypress/e2e/ until all Part A expectations pass.
The approach is practice-first and competition-aligned: every workshop maps to real Module G it titles. You get a green assertion in Module 1, then layer auth edge cases, multi-step registration, stations/reserve, activity journeys, QR scan, and HTTP intercepts.
A complete, deterministic Cypress suite for Module G Part A (specs A1βA8):
| Spec | File | Coverage |
|---|---|---|
| A1 Login | 01_login.cy.js |
Page load, validation, invalid credentials, suspended account, successful sign-in |
| A2 Register | 02_register.cy.js |
Vehicle profile validation; swappable + integrated register |
| A3 Stations | 03_stations.cy.js |
List, filters, compatibility badges, public browse |
| A4 Station detail | 04_station_detail.cy.js |
Open hub, reserve, 409 conflict, block second hold |
| A5 Activity swap | 05_activity_swap.cy.js |
Reserved UI β start β confirm β receipt; cancel |
| A6 Activity charging | 06_activity_charging.cy.js |
Start charge β live status β collect β receipt |
| A7 QR scan | 07_qr_scan.cy.js |
Emulator, valid poster, mismatched payload |
| A8 HTTP errors | 08_http_errors.cy.js |
Protected route redirect, intercept 500, double-submit guard |
- MITS / WorldSkills Web Technologies competitors preparing for Module Gβstyle testing
- Intermediate front-end learners who know HTML/JS but are new (or rusty) with Cypress
- Instructors running SwapLoop / Skill17-style Cypress workshops
Out of scope: Module G Part B (PHPUnit / partner billing). This course ends when the Cypress suite is complete.
By completing this course, you'll be able to:
- β Run the SwapLoop template locally (Node and/or Docker Compose) with Cypress
- β
Use
data-testidselectors and reset domain state withDELETE /api/v1/__reset - β
Implement all Module G Part A specs (
01β08) - β Cover auth, register, stations, reserve, swap, charging, QR, and HTTP error cases
- β
Use
cy.interceptfor forced failures and pending-request guards - β Complete a timed green-suite rehearsal suitable for competition Part A
Required:
- Node.js 20+ (template targets Node 22)
- Basic HTML and JavaScript literacy
- A code editor (VS Code recommended)
Recommended:
- Prior exposure to browser DevTools / network tab
- Docker Desktop (Compose path mirrors the assessment layout)
- A GitHub account for the Git workflow tasks
Tools:
- Cypress 15.x (
cypress/included:15.10.0in Docker) - Node.js mock API (
server.js) serving the rider UI - Optional: Docker Compose (
web+cypressservices)
No prior Cypress experience needed β Module 1 starts from first principles.
β±οΈ Time: 2β3 hours
Get the template running and write the first meaningful Cypress tests against login β visit, query, type, assert, and reset state.
What you'll learn:
- Project layout: read-only
public/,server.js,cypress/e2e/, Docker Compose - Cypress command queue vs synchronous JS intuition
cy.visit,cy.get,.should,.type,.click- Preferring
[data-testid="β¦"]and__resetinbeforeEach
Deliverable: Two green login tests in 01_login.cy.js.
β±οΈ Time: 2β3 hours
Finish A1 β invalid credentials, suspended accounts, successful sign-in β and extract a small signInAsLin() helper for later specs.
What you'll learn:
- Client validation vs API error messages
- Asserting
stations-pagelanding anduser-chipidentity - File-local helper pattern without over-abstracting
Deliverable: Fully green 01_login.cy.js plus reusable sign-in helper.
β±οΈ Time: 2β3 hours
Drive SwapLoopβs two-step registration (vehicle profile β mock Alipay) for swappable and integrated riders.
What you'll learn:
- Multi-step form sequencing in Cypress
- Mode-specific required fields (battery vs connector type)
- Negative path: incomplete profile must not create an account
Deliverable: Fully green 02_register.cy.js.
β±οΈ Time: 3β4 hours
Cover browsing/filtering and the reserve conflict matrix, including forced 409 messaging.
What you'll learn:
- Authenticated list + type filters + public browse
- Navigation from card β station hub
- Happy-path reserve β Activity;
__force-conflict; block second hold
Deliverable: Green 03_stations.cy.js and 04_station_detail.cy.js.
β±οΈ Time: 3β4 hours
Drive full service lifecycles and assert API-backed receipts (never invented amounts).
What you'll learn:
- Arrange preconditions (login + reserve) before Activity assertions
- Swap path: reserved β start β confirm β receipt; cancel path
- Charging path with integrated rider (
chen.wei@β¦): live status β collect β receipt
Deliverable: Green 05_activity_swap.cy.js and 06_activity_charging.cy.js.
β±οΈ Time: 2β3 hours (+ optional timed drill)
Finish edge cases and prove the entire Cypress suite green under time pressure.
What you'll learn:
- QR emulator on
scan.html; valid vs mismatched poster payloads - Protected-route redirect;
cy.interceptfor 500s and double-submit guards - Competition hygiene and full-suite rehearsal
Deliverable: Entire Part A suite green; checklist maps every it to Module G Part A.
- Create your practice repo from the GitHub template: mits-frontend-testing-tutorial-template β Use this template β clone your new repo
- Read Module 1 overview
- Work through Module 1 workshop in your practice repo
- Compare against
module-1/solution/ - Continue through Modules 2β6
A local copy also lives in this course as
cypress-frontend-testing-template/if you prefer not to use GitHub.
In your practice repo (from the template):
npm install
npm start
# if port 3000 is busy: PORT=3080 npm start
# In another terminal:
npm run cypress:open # interactive
# or: npm test # headlessDocker Compose (assessment-style layout) is documented in the template README.
| Password | Role | |
|---|---|---|
lin.xiaoyu@swaploop.test |
password123 |
Swappable rider (SL-48) β default happy path |
chen.wei@swaploop.test |
password123 |
Integrated rider β charging flows |
sun.hao@swaploop.test |
password123 |
Suspended β distinct 403 login failure |
See proejct-task/module-g.md β Part A β Frontend testing (Cypress) only.
| Module | Title | Time | Topics |
|---|---|---|---|
| 1 | Environment + Cypress Basics + First Login | 2β3h | visit/get/type/assert, __reset, testids |
| 2 | Complete Login Suite + Sign-in Helper | 2β3h | A1 complete, validation vs API errors |
| 3 | Registration Flows (A2) | 2β3h | Multi-step forms, rider modes |
| 4 | Stations + Detail & Reserve (A3βA4) | 3β4h | Filters, reserve, 409 conflict |
| 5 | Activity β Swap & Charging (A5βA6) | 3β4h | State machines, API-true receipts |
| 6 | QR Scan + Intercepts + Full Suite (A7βA8) | 2β3h | Emulator, cy.intercept, rehearsal |
- Cypress 15.x β E2E test runner (local or
cypress/includedimage) - Node.js 22 +
server.jsβ static rider UI + Module Cβcompatible mock API - Docker Compose β optional
web+cypressservices (ws26-cypress layout) - Vanilla multi-page HTML/JS β application under test (read-only)
- Cypress command queue and assertion retry
- Stable selectors via
data-testid - Test isolation with
__reset/__force-conflict cy.interceptfor error and timing isolation- Arrange / act / assert readability under competition time pressure
- Read-only app rule (do not edit
public/orserver.js) - Git feature-branch workflow per module
- Prefer UI/API state waits over arbitrary
cy.wait(ms) - Assert receipt amounts from API responses β never invent values
courses/mits-frontend-testing-tutorial/
βββ cypress-frontend-testing-template/ # App under test + Cypress skeletons
β βββ public/ # Rider UI (read-only for students)
β βββ cypress/e2e/ # Spec skeletons (01β08)
β βββ server.js # Static + mock API
β βββ cypress.config.js
β βββ docker-compose.yml
βββ proejct-task/
β βββ module-g.md # Competition outline (Part A focus)
βββ module-1/
β βββ overview.md
β βββ workshop.md
β βββ solution/
βββ module-2/
β βββ overview.md
β βββ workshop.md
β βββ solution/
βββ module-3/
β βββ overview.md
β βββ workshop.md
β βββ solution/
βββ module-4/
β βββ overview.md
β βββ workshop.md
β βββ solution/
βββ module-5/
β βββ overview.md
β βββ workshop.md
β βββ solution/
βββ module-6/
β βββ overview.md
β βββ workshop.md
β βββ solution/
βββ metadata.json
βββ README.md # This file
This tutorial is part of the MITS Pilot program. If you find issues or have suggestions:
- Open an issue describing the problem or suggestion
- For fixes, submit a pull request with a clear description
This project is part of the Marketable IT Skills initiative.
For questions or support, please open an issue in this repository.
Part of the Marketable IT Skills (MITS) initiative