Write tests that catch the cart bugs
intermediate Test design Challenge 17 of 22
The cart page has a single test that adds one product. Three versions of the cart have bugs planted in them. Write tests that catch every one, while still passing on the working cart.
How the cart should behave
- Choose a product in the Product list and press Add. Adding a product that is already in the cart increases its quantity (shown as
× 2) instead of adding a second line. - The total (
data-testid="cart-total") is the sum of price × quantity. The Wireless Mouse costs $35.00. - The coupon
SAVE10takes 10% off, and codes are not case-sensitive:save10works too. A valid code shows “Coupon applied”. - Clear cart removes every item and resets the total to $0.00.
Requirements
- All your tests pass on the working app.
- Each buggy version makes at least one of your tests fail.
Expected output
All tests pass on the working cart, and each buggy version (quantity, coupon case, clearing) makes at least one test fail.
Scenarios (4)
Your tests run once against each version of the demo app. They must pass on the working app and fail on every version with a planted bug.
- ○Working app · must pass
- ○Bug: quantity never increases · must catch
- ○Bug: coupon is case-sensitive · must catch
- ○Bug: Clear cart does nothing · must catch
example.spec.tsRuns against a live demo app
Ctrl/⌘ + Enter to run tests · your code is saved in this browser
Results
Run the tests to see results here.
Demo app
The working app. You can click around it; your tests start from a fresh copy.