Guided shop project · Playwright

Test the cart. Check the order.

A shop can show a success message and still save the wrong order. Build tests that check what the shop actually keeps. Follow the lessons, then bring your checks into a suite.

What you will build

Connected checks for the same shop

Cart changes

Check what the cart keeps after an update.

  • The first quantity enters the cart.
  • A later quantity replaces the earlier quantity.
  • The cart shows the requested total, without adding the quantities together.
Open cart changes →

Stock limits

Check the cart after a request is rejected.

  • An available quantity enters the cart.
  • A quantity above the stock limit shows an error.
  • A rejected quantity does not change the cart.
Open stock limits →

Checkout

Check the order behind the confirmation message.

  • An empty name cannot place an order.
  • The saved order keeps the accepted cart quantity.
  • The cart is empty after the order is placed.
Open checkout →

Your test suite

Bring the checks together with separate setup for each test.

  • A changed cart quantity replaces the earlier quantity.
  • A rejected stock request leaves the cart unchanged.
  • A placed order keeps the cart quantity.
Open your test suite →

A closer look: Check the stock limit

Add an available quantity to the cart. Then request more than the stock limit. Check that the error appears and the cart keeps the earlier quantity.

  • An available quantity enters the cart.
  • A quantity above the stock limit shows an error.
  • A rejected quantity does not change the cart.

What is included

Each task has a short lesson, a starter test and a checklist. Write the missing checks yourself. Use a hint when you need help. Open a worked solution with an explanation when ready.

Run tests checks the working shop. Verify runs your test against the working shop, then checks each planted break separately. It reports whether your test noticed the changed behaviour.

The editor runs supported Playwright commands in your browser. It is not a full local Playwright installation. Use a wide screen for the editor. Your code and verified runs stay in this browser. They do not sync between devices. If storage is blocked, they last until you leave.

Recorded starter test

Stock-limit teaching task · 2026-10-20

Run tests
Your test passed on the working app. A test can pass and still miss a bug.
Verify
0 of 1 planted bugs caught.
Missed: The cart accepts more items than the available stock.
Read the starter test used in this run
import { test, expect } from '@playwright/test';

test('sets an available cart quantity', async ({ page }) => {
  await page.goto('/');
  await page.getByLabel('Quantity').fill('1');
  await page.getByRole('button', { name: 'Update cart' }).click();
  await expect(page.getByTestId('basket-quantity')).toHaveText('1');
});

// Add a check for a rejected quantity.
// Read the stock limit from data-testid="available-stock".
// Check the error and the quantity left in the cart.
Included in either paid course plan. Sign in to open the guided project. These tasks are for learning. They are never used in an assessment. Teaching help is unavailable during an active interview or assessment.

Existing practice problems and Verify stay free. Browse free problems.