Regression Testing Example: A Step-by-Step Walkthrough
Regression testing identifies when a bugfix or new feature breaks existing functionality. It prevents the “one step forward, two steps back” cycle common in high-velocity development. Without it, you ship fixes for reported bugs while silently breaking the core features your users rely on.
This tutorial walks through a concrete regression testing example. We examine a real-world scenario, write a Playwright test, catch a regression, and automate the process.
In this guide
- The scenario
- Step 1: Define the test case
- Step 2: Write the automated test
- Step 3: Run it and catch the regression
- Step 4: Fix and verify
- Step 5: Automate in CI/CD
- Scaling coverage with AI
- High-value regression test examples
- FAQ
The scenario: a fix that breaks everything else
Imagine a standard e-commerce checkout page. It manages two primary business rules:
- Discount Codes: Users enter a code to receive 10% off their order.
- Free Shipping: Orders over $50 qualify for free shipping.
A user reports a bug: the discount field accepts expired codes. A developer corrects the validation logic in the calculateTotal() function. The discount bug is fixed.
However, the fix inadvertently alters how the “Order Total” variable is passed to the shipping calculator. Now, even orders exceeding $50 are charged for shipping. The developer only re-tested the discount field. They did not verify the shipping threshold. A regression is born.
Step 1: Define the regression test case
A successful regression test defines the flow, actions, and expected outcomes precisely. Documentation prevents ambiguity during manual or automated execution.
| Field | Value |
|---|---|
| Test Case ID | REG-001 |
| Title | Free shipping applies to orders over $50 |
| Precondition | User has items totaling $60 in the cart |
| Steps | 1. Navigate to Checkout 2. Verify items total $60 3. Inspect shipping cost line item |
| Expected Result | Shipping cost displays as “$0.00” or “FREE” |
| Priority | Critical (Revenue Impact) |
Step 2: Write the automated test

Manual testing is insufficient for frequent releases. We use Playwright with TypeScript to automate this regression check. This ensures the threshold logic remains intact after every code change.
import { test, expect } from '@playwright/test';
test('verify free shipping threshold remains active over $50', async ({ page }) => {
// Navigate to the store
await page.goto('https://shop.example.com');
// Add a high-value item to trigger the threshold
await page.getByRole('button', { name: 'Add Enterprise Plan' }).click();
// Navigate to checkout
await page.getByRole('link', { name: 'Proceed to Checkout' }).click();
// Assertion: the shipping line must reflect the free threshold.
// We use a stable selector for maximum resilience.
const shippingCharge = page.locator('#shipping-total');
// Verify the baseline behavior
await expect(shippingCharge).toHaveText('FREE');
});
We prioritize text-based selectors and ARIA roles. This approach creates resilient tests that survive UI refactors. Brittle CSS selectors like .btn-blue-rounded cause false positives when styles change.
Step 3: Run the test and catch the regression
Run the suite after implementing the discount code fix:
npx playwright test
The result confirms the failure:
✘ verify free shipping threshold remains active over $50 (1.4s)
Error: expect(locator).toHaveText(expected)
Expected: "FREE"
Received: "$12.00"
Locator: locator('#shipping-total')
The test caught the regression. The discount fix broke the shipping logic. Because we ran this suite, the bug never reaches the production environment.
Step 4: Fix the regression and verify
The developer identifies the error: the calculateTotal() function was returning a string instead of a float after the discount update. The shipping logic failed the total > 50 check because of the type mismatch.
After correcting the data type, we re-run the test:
✓ verify free shipping threshold remains active over $50 (1.2s)
The suite is green. Both the original discount bug and the new shipping regression are resolved.
Step 5: Automate in CI/CD

Regression tests only provide value if they run automatically on every change. Integrate the suite into your GitHub Actions or GitLab CI pipeline so no Pull Request is merged unless all regression checks pass. See how to set up CI/CD pipelines for a full walkthrough.
# .github/workflows/regression.yml
name: Regression Suite
on: [pull_request]
jobs:
test:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Regression Tests
run: npx playwright test
Scaling coverage with AI

The example above covers a known risk. However, the regressions that damage companies most are the “unknown unknowns”: features no one thought to test. Manually writing scripts for every edge case is impossible for modern dev teams.
AegisRunner solves this by automating the discovery process. Our AI crawler explores your application, identifies every interactive element, and generates comprehensive test cases automatically.
- Zero Manual Scripting: Stop writing code for every button and form.
- Auto-Healing: If you rename a class or move a component, our resilient selectors adapt without breaking the build.
- Deep Analysis: Every run includes AI-powered audits for SEO, accessibility (WCAG), and security.
- No Lock-In: Export any generated suite to standard Playwright TypeScript — the same kind of code shown above.
Learn how to automate regression testing to eliminate the maintenance burden.
High-value regression test examples
If you are starting a manual suite, prioritize these high-impact flows first. These are the areas where regressions most directly affect revenue and user retention:
- Authentication: Login, logout, and password reset flows.
- User Onboarding: Signup forms and email verification.
- Search Functionality: Result accuracy and empty-state handling.
- Data Integrity: CRUD operations (Create, Read, Update, Delete) on user profiles or dashboard settings.
- Permissions: Ensuring restricted content remains inaccessible to unauthorized roles.
- Integrations: Verifying third-party APIs (Stripe, HubSpot, Twilio) continue to communicate correctly.
For a deeper look at how to select the right platform for these tests, consult our Regression Testing Tools: The 2026 Buyer’s Guide and the 10 best regression testing software comparison.
Start catching regressions today
Regression testing is the only way to ship code with confidence. Manual walkthroughs are too slow. Hand-coded scripts are too brittle.
AegisRunner offers autonomous regression testing on autopilot. We discover your pages, generate your tests, and catch regressions before your users do.
Start your first crawl in minutes — no credit card required — or compare plans.
Frequently asked questions
What is a simple example of regression testing?
A team fixes a discount-code bug on checkout, but the fix accidentally breaks the free-shipping calculation. A regression test that re-checks the full checkout flow after every change catches the free-shipping breakage immediately, before it reaches production.
How do you write a regression test?
Identify a flow that previously worked (for example, login), define the exact steps and expected outcome, automate those steps with a tool like Playwright or an AI generator, assert the expected result, and run the test automatically on every code change through CI/CD.
What is the difference between regression testing and retesting?
Retesting verifies that a specific reported bug is actually fixed. Regression testing verifies that the fix (or any change) did not break previously working functionality elsewhere. Retesting is narrow; regression testing is broad and preventive.
What are good examples of regression test cases?
High-value cases include login/logout, signup, checkout and payment, form submission and validation, search, and navigation between core pages — critical flows where a regression would directly hurt users or revenue.
Can regression tests be automated?
Yes, and they should be. Automating them lets them run on every commit and deploy. Playwright requires you to write them; AI tools like AegisRunner generate and maintain them automatically from your live app.