Power Your Software Testing with AI Agents and Cloud
The Native AI-Agentic Cloud Platform to Supercharge Quality Engineering. Test Intelligently and Ship Faster.
- TestMu AI (Formerly LambdaTest)
- /
- Use Cases
- /
- Test discount code application at checkout
Test discount code application at checkout
Reject an invalid code, apply a valid one, then check the discount line and the recalculated total.
Published on:
A promo code that fails on launch day burns the ad spend that drove traffic to it. A promo code that applies the wrong percentage is worse, because nobody notices until the margin report.
This use case checks both directions on the Shoplify checkout: a code that should be refused, and a code that should take ten percent off. Four steps, 174 seconds, all passed.
Failure modes in this flow
Discount bugs cluster in a small number of places, and each one needs a different assertion to catch it.
- An invalid code is accepted - the field takes anything and the total silently changes, or the error never appears.
- The badge and the maths disagree - the page confirms "10% off applied" while the line item deducts a different amount.
- The discount does not reach the total - the line item renders correctly but the total is unchanged.
Testing the unhappy path first is the part most teams skip. This test types NOTACODE before it types WELCOME10, so a field that accepts anything fails at step two rather than passing the whole run.
Note: Kane CLI decides assertions on the live page rather than planning them blind, so a discount that applies late is caught at the moment it settles. Try it on your own checkout with TestMu AI. Try free!
Writing the objective
The objective is written so each assertion is a string the shopper can see. The error message is quoted in full, including the code name, because a generic error is a different bug from a correctly targeted one.
---
mode: testing
url: https://my-testing-repo-main.vercel.app/shopify-clone-app?reset=true
max_steps: 45
tags: [shopify, e-commerce, discount]
---
# Shoplify 2.2: Discount code application
Catalog objective: apply a discount code at checkout and verify the reduced total.
Key assertion: discount line item matches the expected percent.
## Add a product and open checkout
Click "Add to cart" on "Heavyweight Cotton Tee", click "View cart", click "Checkout", and verify the order summary shows a Total of "$41.06".
## Apply an invalid code first
Type "NOTACODE" into the "Discount code" field, click "Apply", and verify an error appears reading "Discount code NOTACODE isn't valid for this order."
## Apply the ten percent code
Clear the discount field, type "WELCOME10", click "Apply", and verify a badge appears reading "WELCOME10 (10% off) applied".
## Confirm the discounted total
Verify the summary shows a discount line "Discount (WELCOME10)" of "−$3.20" and a Total of "$37.60".Step four is the arithmetic check. It asserts the discount line reads 3.20 off and the total lands at $37.60, which is what ten percent of the $32.00 subtotal should produce against a $41.06 pre-discount total. Run it with:
kane-cli testmd run tests/shopify/discount-code_test.mdRunning it locally
Four steps, four passes. The first step is the slowest at 60.1 seconds because it chains three navigations, add to cart through to the checkout page, before its assertion.
---
test: ../discount-code_test.md
status: passed
started: 2026-09-15T09:21:50.747Z
duration_s: 174
session_id: 2d3b01a6-5014-4bf3-9c3e-75d277a7f921
---
# Shoplify 2.2: Discount code application - Result
## Add a product and open checkout ✓ passed (60.1s)
md5: e78d860c73d44fa658232026c1a1bde1
Click "Add to cart" on "Heavyweight Cotton Tee", click "View cart", click "Checkout", and verify the order summary shows a Total of "$41.06".
## Apply an invalid code first ✓ passed (33.1s)
md5: 5eb4fb64e9a382ff46fe43df8f7cf2da
Type "NOTACODE" into the "Discount code" field, click "Apply", and verify an error appears reading "Discount code NOTACODE isn't valid for this order."
## Apply the ten percent code ✓ passed (40.9s)
md5: a0c09a7e6123d93a3b59d033832a9860
Clear the discount field, type "WELCOME10", click "Apply", and verify a badge appears reading "WELCOME10 (10% off) applied".
## Confirm the discounted total ✓ passed (35.9s)
md5: cdd2b6341ec07546d92ac66b7fd1ae52
Verify the summary shows a discount line "Discount (WELCOME10)" of "−$3.20" and a Total of "$37.60".| Step | Result | Duration |
|---|---|---|
| Add a product and open checkout | Passed | 60.1s |
| Apply an invalid code first | Passed | 33.1s |
| Apply the ten percent code | Passed | 40.9s |
| Confirm the discounted total | Passed | 35.9s |
Putting it in CI
The result is a promo regression test that can be cloned per campaign by changing two strings. Each campaign gets its own file, and the suite grows without any new code.
For a campaign calendar with several codes live at once, generating the variants beats writing them. Test case generation with Kane CLI covers drafting a family of flows from one description, and live page assertions explains how each check is verified before it is recorded.
Author
Bhawana is a Community Evangelist at TestMu AI with over 3 years of experience creating technically accurate, strategy-driven content in software testing. She has authored 50+ blogs on test automation, cross-browser testing, mobile testing, and real device testing. She also serves as Product Marketing Manager for Kane CLI, the command-line tool that runs browser automation from the terminal using natural-language flows in a real Chrome browser. Bhawana is certified in KaneAI, Selenium, Appium, Playwright, and Cypress, reflecting her hands-on knowledge of modern automation practices. On LinkedIn, she is followed by 6000+ QA engineers, testers, AI automation testers, and tech leaders.
Discount Code Testing FAQs
Did you find this page helpful?
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance
- Advanced access controls
- Advanced data retention rules
- Advanced Local Testing
- Premium Support options
- Early access to beta features
- Private Slack Channel
- Unlimited Manual Accessibility DevTools Tests




