Test the whole buying journey and write a pre-release report
Add unit tests for price and stock maths, an automated browser test of a full test-mode purchase, accessibility and speed checks, and a plain-language test report.
You will have: Commands that prove the store works (npm test and an end-to-end run) and a TEST_REPORT.md that says whether it is ready to release.
Before you start
- Episode 18 is done and merged, or at least committed, so you are testing the hardened version
- Your payment gateway is still in test mode and the webhook test secret is in .env.local
- Make sure the local database shop_local is running; the agent will create a separate shop_test database for tests
- Close other work in the project folder so the browser tests are not disturbed
Make it yours
Change the example (a fashion store) to your own. Your answers are saved in this browser and used in every episode.
Other series keywords (3)
Your prompt
Paste into: Your AI agent (Claude Code or Codex) opened in your project folder. Start a fresh session so it reads your project notes first.You are a careful senior test engineer working inside my project folder. The store is "Thread & Needle", a fashion e-commerce store selling women's and men's clothing, shoes and accessories in United States, charging in USD, with payments through Stripe at threadandneedle.com. Prove that it works and tell me honestly if it is not ready. I am not a programmer, so explain any technical word in a few words.
Plan first: read the cart, pricing, stock, checkout, order and webhook code, then show me a test plan (what you will test and what you will not) and wait for my OK before changing anything.
Tasks:
1. Unit tests with Vitest for the money and stock maths: line totals, cart totals, shipping rules, tax if the store charges it, discounts if any, rounding in the smallest unit of USD, refund limits, and stock never going below zero. Include edge cases: empty cart, quantity zero, huge quantities, two buyers for the last item. If you find a bug, show it to me, fix it in a separate commit and keep the test.
2. A separate test database called shop_test with migrations applied and a small seed. Tests must refuse to run if the database URL points anywhere except a local database with test in its name. Never touch production data.
3. End-to-end tests with Playwright for the full buying journey in test mode: open the home page, find a product, add it to the cart, change quantity, check out as a guest, reach the Stripe hosted page, then complete payment. Do not try to automate the gateway's hosted page if it blocks automation. Instead, create the order up to the redirect, then send a correctly signed test webhook to the local site, as the gateway would, and confirm the order becomes paid, stock drops once, and a second delivery of the same webhook changes nothing. Capture the order confirmation email through a test stub, not real sending.
4. More end-to-end tests: customer sign-up and login, a wrong password, an admin marking the order shipped, an admin refund, and a customer being refused access to /admin.
5. Accessibility checks with axe through Playwright on the home, product, cart, checkout, login and an admin page. Fix serious and critical problems such as missing labels, low contrast and keyboard traps, and list the rest.
6. Performance checks with Lighthouse on the home, product and cart pages, on a production build run locally. Report the scores and the main causes of slowness (large images, scripts). Fix the easy wins, such as image sizes and missing dimensions, and list the rest. Do not invent target numbers; report what you measure.
7. Add npm scripts: test, test:e2e and a single check script that runs type-check, lint, unit tests and a production build.
Security rules: never print, log or commit secrets; use only test keys; keep test data fake.
Verify: run everything and show me the real output, including failures. Do not hide or skip failing tests to look green.
Then write TEST_REPORT.md with: what was tested, results, bugs found and fixed, known gaps, and a clear ready or not ready verdict for release with reasons.
Commit on a feature branch with a clear message.
Report back in this format: 1) What was done. 2) What I should check myself. 3) Anything that needs my decision.Review the prompt, then copy it. Never paste real passwords or API keys into a chat.
How to check it worked
- npm test passes and the output lists tests for totals, rounding, refunds and stock
- The end-to-end run shows the whole purchase passing and a screen recording or trace you can open
- Sending the same signed test webhook twice leaves one paid order and stock reduced once
- Running the tests against a non-test database is refused with a clear message
- The accessibility results list zero serious or critical problems, or name each remaining one
- TEST_REPORT.md ends with a ready or not ready verdict and the reasons
Sample result
Fashion store exampleExample result for the fashion store: the closing part of the test run and the report. Numbers are illustrative.
If something goes wrong
- End-to-end tests fail only sometimes (flaky).
- Ask the agent to replace fixed waits with waiting for visible elements, to run each failing test ten times, and to report the cause instead of adding retries.
- The signed test webhook is rejected.
- The test needs the same webhook secret that the local server reads. Ask the agent to check that both use the test secret from .env.local, without printing it, and that the raw request body is passed to the signature check.
- Playwright says a browser is missing.
- Ask the agent to run the Playwright browser install command for your operating system, then rerun. Allow a few minutes for the download.
- Lighthouse scores vary a lot between runs.
- Run it against a production build, not the development server, close other apps, and ask the agent to take the median of three runs. Treat scores as a guide, not a promise.
Free. Vitest, Playwright, axe and Lighthouse are free tools. Run the tests only in test mode; the payment gateway test keys never charge real cards.
More in Secure and test
This is part of the series Build a secure, no-cost e-commerce website with AI agents. See all 24 episodes, the tools used and answers to common questions on the series page.