Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MITS Frontend Testing Tutorial

From first cy.visit to a green Module G Cypress suite β€” competition-ready frontend testing.

Modules Difficulty Duration Cypress Status

Powered by Marketable IT Skills (MITS) initiative


πŸ“š Overview

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.

What You'll Build

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

Who This Course Is For

  • 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.


🎯 What You'll Learn

By completing this course, you'll be able to:

  • βœ… Run the SwapLoop template locally (Node and/or Docker Compose) with Cypress
  • βœ… Use data-testid selectors and reset domain state with DELETE /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.intercept for forced failures and pending-request guards
  • βœ… Complete a timed green-suite rehearsal suitable for competition Part A

πŸ“‹ Prerequisites

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.0 in Docker)
  • Node.js mock API (server.js) serving the rider UI
  • Optional: Docker Compose (web + cypress services)

No prior Cypress experience needed β€” Module 1 starts from first principles.


πŸ“– Course Structure

Module 1: Environment, Cypress Mental Model & First Login Assertions

⏱️ 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 __reset in beforeEach

Deliverable: Two green login tests in 01_login.cy.js.


Module 2: Complete Login Suite (A1) + Sign-in Helper

⏱️ 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-page landing and user-chip identity
  • File-local helper pattern without over-abstracting

Deliverable: Fully green 01_login.cy.js plus reusable sign-in helper.


Module 3: Registration Flows (A2)

⏱️ 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.


Module 4: Stations List + Station Detail & Reserve (A3–A4)

⏱️ 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.


Module 5: Activity Journeys β€” Swap & Charging (A5–A6)

⏱️ 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.


Module 6: QR Scan, Intercepts & Full-Suite Rehearsal (A7–A8)

⏱️ 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.intercept for 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.


πŸš€ Getting Started

Option 1: Follow the modules sequentially

  1. Create your practice repo from the GitHub template: mits-frontend-testing-tutorial-template β†’ Use this template β†’ clone your new repo
  2. Read Module 1 overview
  3. Work through Module 1 workshop in your practice repo
  4. Compare against module-1/solution/
  5. 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.

Option 2: Run the template app + Cypress

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         # headless

Docker Compose (assessment-style layout) is documented in the template README.

Seed accounts (tests only)

Email 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

Competition outline

See proejct-task/module-g.md β€” Part A β€” Frontend testing (Cypress) only.


πŸ“š Modules

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

πŸ› οΈ Technologies & Concepts

Core Technologies

  • Cypress 15.x β€” E2E test runner (local or cypress/included image)
  • Node.js 22 + server.js β€” static rider UI + Module C–compatible mock API
  • Docker Compose β€” optional web + cypress services (ws26-cypress layout)
  • Vanilla multi-page HTML/JS β€” application under test (read-only)

Key Concepts

  • Cypress command queue and assertion retry
  • Stable selectors via data-testid
  • Test isolation with __reset / __force-conflict
  • cy.intercept for error and timing isolation
  • Arrange / act / assert readability under competition time pressure

Professional Practices

  • Read-only app rule (do not edit public/ or server.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

πŸ“ Project Structure

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

🀝 Contributing

This tutorial is part of the MITS Pilot program. If you find issues or have suggestions:

  1. Open an issue describing the problem or suggestion
  2. For fixes, submit a pull request with a clear description

πŸ“ License

This project is part of the Marketable IT Skills initiative.

πŸ”— Resources

πŸ’¬ Support

For questions or support, please open an issue in this repository.


Part of the Marketable IT Skills (MITS) initiative

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages