Write tests that catch the search bugs
intermediate Test design Challenge 18 of 22
The shop’s search has a single test, and it passes even when search is badly broken. Three versions of the shop have bugs planted in them. Write tests that catch every one, while still passing on the working shop.
How search should behave
- Typing in Search products and pressing Search lists only the products whose name contains the text.
keyboardmatches three products: Mechanical, Wireless and Compact Keyboard. - Matching ignores case:
MOUSEfinds “Wireless Mouse”. - When nothing matches, the page shows “No products found” and no product rows.
Each product is a row with data-testid="product-row".
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 shop. "Ignores the query", "case-sensitive" and "no empty state" each make 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: search ignores the query · must catch
- ○Bug: search is case-sensitive · must catch
- ○Bug: no empty state · must catch
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.