A kata project to practice Test Driven Development with Nextjs.
The app enables to launch space missions by retrieving an available rocket, free astronauts, selecting a destination planet, explore estimated costs and launch the mission.
The goal is to implement business requirements described under #1 Launch a mission using Test Driven Development XP technique.
This is a Next.js project bootstrapped with create-next-app
.
Create a Neon database
- Sign up to https://neon.tech
- Create a new project
- Click the "Connect to your database"
- Copy the connection string/url
- Create the
.env
file in this repository:
DATABASE_URL="postgresql://<user>:<password>@<endpoint_hostname>.neon.tech:<port>/<dbname>?sslmode=require"
- Add migration and seed the table with default row:
CREATE TABLE public.rockets (
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
model text NOT NULL UNIQUE,
capacity smallint NOT NULL,
manufactured_date text NOT NULL,
state text DEFAULT 'AVAILABLE' NOT NULL,
PRIMARY KEY (id)
);
CREATE INDEX state_index ON public.rockets (id, state);
INSERT INTO public.rockets (model, capacity, manufactured_date, state)
VALUES ('Falcon 9', 7, '2025-02-26T16:00:00.000Z', 'AVAILABLE')
In the .env
file, add the following line:
API_URL="http://localhost:3000/api"
Run the development server:
pnpm dev
Open http://localhost:3000 with your browser to see the result.
The auto-updates are enabled in favour to see made code changes as you edit files.
The project is configured for different types of tests.
⚠️ Docker is required to run tests. Make sure it's installed and running before executing the tests.
Unit tests (vitest) will execute files matching __tests__/*.test.ts
pattern:
pnpm test:unit
Integration tests (cypress) will pick files matching __tests__/*.test.integration.ts
pattern:
pnpm test:integration
⚠️ For Integration tests, the app is compiled and running with theNEXT_PUBLIC_PHASE=test
environmental variable.
This project is maintained by Nik Sumeiko.
Here's a link: https://www.withnik.com
(Let's check if you're eligible to join the program)