Investigations

BDD Health Quest

TypeScript February 2026

React + TypeScript health adventure game with a full BDD test suite using Cucumber.js and Playwright.

This one started as a way to demonstrate BDD testing properly — not the watered-down version where you just slap Gherkin syntax on top of unit tests, but the real thing with Cucumber scenarios driving Playwright browser automation against a running React app.

The game itself is a health adventure: you've got a real-time health bar that decays over time, a step counter where each step earns 10 HP, a donut shop (max 5 donuts, each restores 50 HP), and a name editor with live validation. Simple enough to understand at a glance, complex enough to write meaningful test scenarios.

The architecture follows a proper three-layer BDD pattern: Feature files written in plain English that anyone can read, step definitions that translate those into actions, and Playwright driving a real browser underneath. There are 23 Cucumber scenarios across 5 feature files covering the full application.

State management is a single React Context (GameContext) that holds health, maxHealth, steps, donuts, and playerName. I deliberately kept it simple — the point was the testing approach, not the state management library of the week.

What this project demonstrates

23 Cucumber BDD scenarios across 5 feature files
3-layer test architecture: Gherkin → Step Definitions → Playwright
Real-time health bar with decay mechanic
Donut shop with purchase limits and HP restoration
Name editor with live validation (5-7 characters)
Single React Context for all game state

Technologies

ReactBDDCucumber.jsPlaywrightTesting

© 2026 Jonathan Leahy · v0.8.1-31-g196fa14