Tagged: testing
Part 1: The App Under Test
See how the suite of this series is laid out, in four sections that each have a job, then build the small app it tests: a quest board with a Vue frontend, a Hono API and a PostgreSQL database.
Intermediate35 minPart 2: Your First Playwright Test
Install Playwright, let it start the app by itself, and write a test that opens the quest board in a real browser and adds a quest. Then find out why a green test can still be wrong.
Intermediate20 minPart 3: One Config, Four Projects
Split the suite into four Playwright projects, one for each layer of the app: database, backend, frontend and end to end. Each gets a first small test that shows what kind of test lives there.
Intermediate20 minPart 4: A Database for Every Worker
Give every parallel worker its own copy of the database, made from a template that the real migrations build, and every test empty tables. Tests then run in parallel and in any order, and your development data is left alone.
Intermediate25 minPart 5: Testing the Database
Fill the database section: tests for the defaults and constraints of the table, for the queries the app sends, and one test that notices when schema.ts has changed and the migration for it is missing.
Intermediate25 minPart 6: Testing the Backend
Let every worker start its own copy of the API on its own database, then test every endpoint with real HTTP requests: the status, the body, and the row that is in the database afterwards.
Intermediate25 minPart 7: Testing the Frontend
Test the page in a real browser while the test plays the API: a page object, a guard against requests nobody mocked, and twelve tests for states a real backend rarely shows, from loading to unreachable.
Intermediate30 minPart 8: End to End, Through All Layers
Build the frontend, let every worker's own server hand it out, and write five tests that go through browser, API and database at once. After this, no test touches your development setup any more.
Intermediate25 minPart 9: When a Test Fails
Break the app on purpose and follow the trail: which sections turn red, what the error says, and how the trace shows the page, the actions and the network at the moment it went wrong.
Intermediate25 minPart 10: A Login for the Quest Board
The app grows: everyone may still read the quest board, but only members who are logged in may change it. Build the login through all three layers, run the suite, and read why half of it turns red.
Intermediate30 minPart 11: Log In Once, Test Everywhere
Let a setup project log in a single time, save the cookie as storage state, and start every test that needs a member with it. The red tests turn green without a change, and the login gets tests of its own in all four sections.
Intermediate35 minPart 12: Accessibility Checks With axe
Let axe look at four states of the quest board on every run, fix what it finds, and then fix what it could not find: a field whose label nobody ever sees. An ARIA snapshot pins down what a screen reader is told.
Intermediate20 minPart 13: Visual Comparisons
Take pictures of the quest board and let Playwright compare them on every run, so a CSS change that moves something shows up as a failed test. The pictures are always made in the same container, because that is the only place where they compare well.
Intermediate25 minPart 14: The Tests in Your Pipeline
Let GitHub or GitLab run all four sections on every push, in the same container that runs them on your machine, with a database beside it and the report kept for every run, red ones included.
Intermediate20 min