Medusa Testing: How to Test Your Commerce Application with testRigor
|
|

Medusa provides an open-source commerce core and a framework for building custom commerce applications. With Medusa, developers can build a storefront around the commerce backend while merchants manage products, orders, customers, and inventory through Medusa Admin. Medusa testing helps teams verify that these components continue to work together as their application evolves.
Imagine publishing a new product in the Admin dashboard. It looks correct there, but shoppers cannot find it on the storefront. Or perhaps checkout creates an order, yet the warehouse cannot fulfill it. Because the storefront and Admin communicate with the backend through APIs, testing one interface alone leaves important gaps.
For developers, QA teams, and merchants running a Medusa-powered store, a good regression suite should follow the life of an order, from product publication to purchase and fulfillment. It should also check the rules that control prices, stock, and customer access.
What Should Medusa Testing Cover?
- Product browsing, variant selection, cart, and guest checkout
- Customer registration, order history, and saved addresses
- Product publication, categories, variant pricing, and unique SKUs
- Stock availability and reservations
- Draft order creation, editing, and conversion
- Promotion creation, eligibility, and redemption
- Fulfillment, shipment, delivery, returns, and exchanges
- Administrator authentication, teammate invitations, and customer groups
Prioritize checkout and the transition from storefront to Admin first. For example, if your business sells multiple sizes or colors, verify the selected variant through checkout rather than checking only that the product name appears.
What Medusa Already Tests
The Medusa repository includes unit and integration tests, with HTTP and module integration suites under integration-tests. Medusa also documents its integration testing tools for application developers. These tests exercise server behavior, including interactions with a database, without requiring a shopper to navigate the storefront.
However, passing framework tests cannot establish that your particular storefront renders the correct price, submits the right variant, or displays an order confirmation. Custom workflows, frontend changes, payment providers, and fulfillment integrations introduce additional paths that your application needs to validate.
Unit Testing in Medusa
Unit tests are useful for isolated logic, such as a custom discount calculation, a validation function, or a rule that determines whether a product is eligible for a business-specific promotion. Developers can test these rules quickly and include boundary values without preparing an entire store.
For instance, a pricing function might correctly calculate a 10% reduction while the checkout still sends an incorrect product ID. The function test protects the calculation; a separate integration or browser test must cover how the application uses it.
Integration Testing in Medusa
Medusa’s architecture separates HTTP endpoints, workflows, modules, and persistence. Integration tests can verify the behavior across these boundaries. For example, a test can submit an order request and inspect the resulting order, reservations, and inventory records.
Using the Medusa integration test runner, developers can exercise HTTP routes and obtain access to the application container. Add integration tests for custom modules and workflows, particularly when they interact with payment, fulfillment, or external inventory systems.
A Medusa testing strategy can complement those checks with independent API assertions after browser tests. In the Admin example discussed later, API helpers prepare controlled records and verify commerce outcomes after the browser cases finish.
End-to-End Medusa Testing
End-to-end tests exercise a complete business process through the interfaces that people use. For a Medusa store, a representative journey spans product discovery, variant selection, checkout, order creation, and merchant fulfillment. Testing the handoff matters because the shopper and merchant see different applications connected to the same commerce backend.
Start with a small set of scenarios and extend coverage as the store gains new functionality. In addition to successful purchases, test rejected inputs, such as duplicate SKUs or reservations above available stock. These cases help distinguish expected validation from unexpected errors.
testRigor
testRigor lets teams express browser actions and assertions in plain English. A QA engineer can describe selecting a size, applying a promotion, or looking up an order by its generated email without writing a locator for each action. Developers can also combine browser steps with API testing and reusable rules when they need to prepare records or check backend results.
This is particularly useful when a merchant and developer need to review the same scenario. Both can see which business result the test expects, while the developer can add technical verification where needed.
Selenium
Selenium is an open-source browser automation framework with language bindings for several programming languages. It offers detailed browser control and works well for teams with an established coded test framework. However, those teams must maintain the code and element locators as their storefront and Admin interface evolve.
Playwright
Playwright provides browser automation with features such as auto-waiting, browser contexts, and tracing. It is a practical option for TypeScript-oriented Medusa teams. Compared with a plain-English suite, it offers direct programmatic control, while test authors generally need to work with code.
Medusa Testing with testRigor: Set Up Your Test Suite
- Step 1: Log in to testRigor.
- Step 2: Create a test suite and name it Medusa Commerce Regression. Choose WebDesktopChrome for the browser examples.
- Step 3: Enter your staging storefront URL as the starting URL. For an Admin-only suite, use the Admin URL instead. Configure the browser and operating system.
- Step 4: Create the suite. If you want to write these examples manually, skip AI-generated cases.
- Step 5: Click Add Test Case, enter the description and steps, then select Add and Run.
Prepare a Safe Test Environment
Use a separate staging environment with both the storefront and backend connected to the same test database. Prepare representative product variants, a region, currency, sales channel, shipping profile, available inventory, and shipping methods. In particular, use sandbox payment providers or a manual payment configuration so no real customer is charged.
The September browser reports use a sample storefront at http://localhost:8000 and Admin at http://localhost:9000/app, with Denmark, EUR, Standard Shipping, and Manual Payment. Their Medusa version is not specified. By contrast, the November Admin fixture uses an isolated source build of Medusa 2.23.0, a tax-free EUR region, test-owned records, and no storefront.
Do not assume that fixture data or labels match between the environments. Use your own staging URLs and configure private-network access when necessary. For local instances, refer to the testRigor CLI documentation.
Test Data and Reusable Rules
Store environment URLs and test credentials in Test Data. The September and November suites use different names for administrator credentials, so the following table keeps those distinctions visible.
| Stored value | Purpose |
|---|---|
homePrefix |
Storefront URL in the September cases |
username / password |
September Admin credentials |
adminEmail / adminPassword |
November Admin credentials |
e2eInventory / e2eWarehouse |
Prepared inventory item and location for TC-05 |
guestEmail |
Generated email used to locate the order |
Generate unique emails, promotion codes, and temporary product names when creating records. This avoids many collisions and, in cross-interface cases, gives the test a reliable way to find the same record after switching to Admin. Nevertheless, clean up test-created records or reset a disposable environment between runs.
Test Case: Complete a Guest Purchase
The September guest purchase case starts on the sample storefront and verifies a purchase of Medusa T-Shirt, size S and color White. It checks the selected variant in the cart and the product and generated email on the final confirmation. Adapt the labels if your storefront uses a different design.
Step 1: Choose a Product Variant
click "Shirts" below "Categories" check that page contains "Medusa T-Shirt" click "Medusa T-Shirt" click exactly "S" click "White" click "Add to cart"

Step 2: Verify the Cart
check that page contains "Cart (1)" click "Cart (1)" check that page contains "Go to checkout" check that page contains "Medusa T-Shirt" check that page contains "S / White" click "Go to checkout"

Step 3: Enter the Shipping Address
check that page contains "Shipping Address" enter "Jane" into "First name" enter "Doe" into "Last name" enter "123 Main Street" into "Address" enter "2100" into "Postal code" enter "Copenhagen" into "City" select "Denmark" from "Country" generate unique email, then enter into "Email" and save as "guestEmail" click "Continue to delivery"
Step 4: Select Delivery and Payment
check that page contains "Standard Shipping" click "Standard Shipping" click "Continue to payment" check that page contains "Manual Payment" click "Manual Payment" click "Continue to review"
Step 5: Place the Order and Verify the Confirmation
check that page contains "Place order" click "Place order" check that page contains "Thank you!" check that page contains "Your order was placed successfully." check that page contains "Medusa T-Shirt" check that page contains stored value from "guestEmail"

Complete Guest Purchase Test Case
click "Shirts" below "Categories" check that page contains "Medusa T-Shirt" click "Medusa T-Shirt" click exactly "S" click "White" click "Add to cart" check that page contains "Cart (1)" click "Cart (1)" check that page contains "Go to checkout" check that page contains "Medusa T-Shirt" check that page contains "S / White" click "Go to checkout" check that page contains "Shipping Address" enter "Jane" into "First name" enter "Doe" into "Last name" enter "123 Main Street" into "Address" enter "2100" into "Postal code" enter "Copenhagen" into "City" select "Denmark" from "Country" generate unique email, then enter into "Email" and save as "guestEmail" click "Continue to delivery" check that page contains "Standard Shipping" click "Standard Shipping" click "Continue to payment" check that page contains "Manual Payment" click "Manual Payment" click "Continue to review" check that page contains "Place order" click "Place order" check that page contains "Thank you!" check that page contains "Your order was placed successfully." check that page contains "Medusa T-Shirt" check that page contains stored value from "guestEmail"
Execution Results
Once the tests finish running, testRigor provides detailed execution reports, including test status, execution time, screenshots for each step, and logs. If a test fails, you can review the exact step where the issue occurred and see what the application looked like at that moment.
All ten test cases covering storefront and administrative workflows passed successfully. In addition, a separate GitHub Actions execution against Medusa 2.23.0 successfully completed nine Admin test cases, covering areas such as product management, inventory reservations, draft orders, promotions, and fulfillment.
These examples demonstrate how testRigor can help teams validate both the customer-facing experience and the administrative operations behind a Medusa-powered commerce application.
High-Value Medusa Testing Scenarios
Once checkout works, extend your Medusa testing suite across merchant operations and customer accounts. The following cases come from the example browser reports and the Admin contribution. Where a suggested extension goes beyond the assertions in those cases, it is identified as a recommendation.
1. Publish Products and Verify Variant Pricing
A product that appears in Admin may still be absent from a customer-facing sales channel. In the September product case, the merchant generates a unique title, selects Default Shipping Profile, enters a EUR 10 price, and publishes. The shopper then opens Store, sorts by Latest Arrivals, finds the generated title, and buys that product.
open url stored value "homePrefix" click "Menu" click "Store" check that page contains "All products" click "Price: Low -> High" click "Latest Arrivals" check that page contains stored value from "productTitle" click stored value from "productTitle" using OCR check that page contains "Add to cart" click "Add to cart"
The November TC-04 takes a different approach: it creates four size/color combinations and deliberately enters the same SKU twice. After checking the unique-SKU error, it corrects the duplicate, saves as a draft, reloads, and checks each SKU and EUR price (11, 12, 21, and 22) before deleting the product. Add a separate published-product price assertion on your storefront if that is important to your business.
TC-03 also creates, edits, and deletes a category, verifying its persisted name and description after reload. Since the status badge identifies the correct menu more reliably than the duplicated category name, the case targets the button next to Public.
2. Reject Excess Reservations and Restore Stock
An inventory reservation should reduce available stock without changing physical stock. In the November fixture, TC-05 begins with ten units at a dedicated location. First, it attempts to reserve eleven and checks the quantity validation. Next, it reserves three units and verifies that seven remain available.
medusa-admin-sign-in click "Inventory" click "Reservations" click "Create" click "Item to reserve" click stored value "e2eInventory" click "Location" click stored value "e2eWarehouse" enter "11" into "Quantity" click "Create" check that page contains "Minimum quantity is 1 and maximum quantity is 10" enter "3" into "Quantity" enter "E2E reservation lifecycle" into "Description" click "Create" reload check that page contains "10" to the right of "In stock at this location" check that page contains "7" to the right of "Available at this location" check that page contains "3" to the right of "Reserved at this location"

The test then edits the reservation to five units, checks the available and reserved quantities, and deletes it. After returning to the inventory item, the warehouse row must again show 10 in stock, 0 reserved, and 10 available. This last assertion checks the business effect of deletion rather than only the disappearance of the reservation record.

3. Create, Convert, and Edit Draft Orders
Draft orders are useful when staff create orders on behalf of customers. The September draft-order case creates a draft and converts it, checks Order placed and the absence of Convert to order, then searches for the associated customer email in the Orders list. In contrast, TC-06 checks whether canceling a draft edit leaves the original quantity and total unchanged.
Its starting draft contains two units totaling €50.00. When the merchant changes the quantity to three, the edit screen shows 75.00 EUR. Canceling must preserve the original €50.00 after reload. Saving the same edit must persist €75.00 and a quantity of three. Both paths matter: a save button that works does not guarantee that cancel discards changes.
4. Create and Redeem Promotions
In the September promotion test, the merchant creates an active Amount off order promotion with a generated code and EUR 5 value. The shopper applies the code in checkout and the test verifies the applied code and the presence of a Discount label. It finishes by checking order confirmation and Discount. However, that case does not assert the exact monetary reduction.
check that page contains "Shipping Address" click "Add Promotion Code(s)" enter stored value "promoCode" into input to the left of "Apply" click "Apply" check that page contains "Promotion(s) applied:" check that page contains stored value from "promoCode" check that page contains "Discount"
For a stronger pricing assertion, November TC-08 creates a 10% product-scoped promotion in Admin. The prepared draft starts at EUR 60; applying the code reduces the total to EUR 55 with a €5.00 discount. Removing the code restores EUR 60. Add separate storefront cases that cover an ineligible product and the exact discount displayed at checkout.
5. Verify Customer Accounts and Saved Addresses
The September registered-customer case creates an account using a generated email, signs in through registration, completes checkout, and opens the account order history. It checks that the Orders page contains Medusa T-Shirt. For greater specificity, capture the order identifier and verify that exact order in history.
Another case creates a shipping address in the account, selects it from Choose an address during checkout, and confirms the purchase. This checks that a saved address can be reused rather than merely displayed in the address book. Extend the scenario to address editing and deletion if your customers rely on them.
6. Fulfill Orders and Handle Partial Shipments
The September delivery case places a storefront order, opens Admin, and searches by the generated guest email. It checks that a single matching order is not fulfilled, creates a fulfillment, marks it shipped, and marks it delivered. The final assertions check Delivered, Items delivered, and Items shipped.
Meanwhile, November TC-09 prepares an order for three units from a warehouse with ten in stock. It fulfills and ships two units, checks the Partially fulfilled and Partially shipped statuses, and verifies the remaining inventory quantities. This tests a different situation from the full-delivery case.
| Inventory measure | Before fulfillment | After shipping two |
|---|---|---|
| In stock | 10 | 8 |
| Reserved | 3 | 1 |
| Available | 7 | 7 |
The unchanged available quantity is expected for this fixture: two reserved units leave physical stock, while one remains reserved. Independent API postchecks add evidence beyond the visible UI. Neither scenario establishes that a real carrier collected or delivered a parcel.
7. Verify Returns and Exchanges
Two September cases start with storefront orders that the merchant fulfills and marks delivered. The return case creates a return for the T-shirt, selects European Warehouse, confirms the return, receives the item, and verifies the message 1x items return received.
check that page contains "1x items return requested" click "Receive items" check that page contains "Items received" click "Save" check that page contains "1x items return received"
The exchange case selects the original T-shirt as inbound and an M / White variant as outbound, selects Standard Shipping, and confirms the exchange. Its final checks establish that the exchange can be confirmed, with Cancel Exchange visible and Confirm Exchange absent. They do not establish receipt of the inbound item, shipment of the replacement, or a refund. Add those downstream checks where your workflow requires them.
8. Check Admin Access and Customer Groups
November TC-02 rejects an invalid password before signing in with valid credentials. The September teammate case exercises a longer onboarding path: invite a new user, copy the invitation link, log out, register the invited user, and sign in with the new credentials. It then logs out, reopens the same invitation, attempts to register again, and checks The invite is invalid or has expired. Because the test copies the link from Admin, it does not verify invitation email delivery.
For customer groups, TC-07 adds a customer to an initially empty group, checks membership from both group and customer views after reload, and removes that membership. Finally, it verifies that the customer still exists without the group. This distinction is important when group membership controls commercial terms. Test those terms separately if they drive your pricing or permissions.
Reusable Rules for Medusa Testing
Repeated sign-in steps are good candidates for reusable rules. For example, the November suite uses the rule medusa-admin-sign-in from its default Admin start URL. Define the rule with the same name before invoking it.
check that page contains "Welcome to Medusa" enter stored value "adminEmail" into "Email" enter stored value "adminPassword" into "Password" click "Continue with Email" check that page doesn't contain "Continue with Email"
Call the rule at the start of an Admin case, then assert a page-specific result. For cross-interface tests, navigate to the Admin URL first. Similarly, teams can extract repeated checkout steps into rules while keeping the order confirmation and business assertions in the individual cases.
For more information, see the Reusable Rules documentation.
Medusa Testing Tips for Reliable Automation
- Keep storefront and Admin connected to the same backend. Otherwise, a newly published product or order may be missing for environmental reasons.
- Verify persistence. Reload after changing a draft, category, or customer group. A transient success banner alone cannot establish that the data survives.
- Track the intended record. Use generated emails and product titles instead of choosing the first order or product in a list.
- Check the values that carry business meaning. In particular, assert totals, SKU mappings, warehouse quantities, and fulfillment states.
- Prepare controlled fixtures. The Admin suite requires test-owned inventory and order infrastructure before its cases run; merely rerunning saved cases does not provision that data.
- Investigate retries. A successful retry can hide readiness or timing problems. Examine the failing step and distinguish an application defect from a browser connectivity issue.
When automating your own storefront, wait for meaningful content after a navigation or mutation. In addition, use stable visible labels and relative references where the same text occurs multiple times.
Running Medusa Admin Tests in GitHub Actions
The example harness is a fork-only draft contribution, not an upstream Medusa feature. It builds the workspace packages from the checked-out source, provisions a disposable application with PostgreSQL, and runs Admin browser cases alongside native testing. It does not launch the September storefront or execute those ten cases.
The workflow is manual and opt-in, without scheduled or automatic pull request triggers. This allows the suite owner to control hosted test execution, credentials, and access. A staging-based suite does not require this harness.
Configure a Dedicated Suite
In GitHub, open Settings, then Secrets and variables, and Actions. Configure the following values for the dedicated Chrome desktop suite:
| Type | Name | Purpose |
|---|---|---|
| Variable | TESTRIGOR_SUITE_ID |
Identifies the suite |
| Secret | TESTRIGOR_CI_TOKEN |
Authenticates execution |
| Variable | TESTRIGOR_TUNNEL_VERIFIED |
Enable only in the controlled tunnel verification process described in the harness README |
Dispatch Admin E2E (opt-in) with run_cloud=true. Missing configuration or opt-in skips the browser job. For the controlled first dispatch, follow the README and verify the login result before relying on the tunnel. A tunnel registration alone does not establish that the remote browser can reach Admin.
Run the Fixture and Browser Checks
The harness uses CLI 3.0.0 and an HTTPS loopback proxy. It verifies the built Admin HTML and authentication, prepares test-owned records, validates syntax, and runs the login case before launching the nine-case suite. Cases run sequentially with whole-test retries disabled.
testrigor test-suite validate-syntax "$TESTRIGOR_SUITE_ID" \ --test-cases-path 'tests/E2E/test-cases/**/*.yaml' \ --rules-path 'tests/E2E/rules/**/*.yaml' bash tests/E2E/ci-run.sh login login-https bash tests/E2E/ci-run.sh full full-https
The job checks CLI status, JUnit counts, and independent commerce results before collecting sanitized logs. Cleanup is attempted even after failures, and the disposable database is removed. In a persistent environment, however, shipped orders may remain in history, so use dedicated test infrastructure rather than production records.
Follow the complete harness README for local commands, certificate handling, cleanup, and suite ownership. Keep tokens out of source files and command arguments; avoid overlapping executions on the same suite.
When to Run Your Medusa Testing Suite
Make Medusa testing part of your release process. Run a quick purchase and Admin smoke test after changes to the storefront, commerce backend, or integrations. Before a promotion launches, also verify eligibility and the expected discount. After a warehouse or shipping configuration changes, prioritize reservation and fulfillment scenarios.
For larger releases, add customer accounts, draft orders, returns, and exchanges. Finally, run selected scenarios regularly against staging to catch configuration changes that happen independently of your application code. Keep the source-built Admin workflow manual unless your team explicitly chooses a different trigger and execution policy.
Conclusion
Medusa gives teams control over the commerce backend and the customer-facing experience. That flexibility makes it important to test the interaction between them: a product should be available to buy, an order should reach the merchant, and stock should reflect what has been reserved or shipped.
Start your Medusa testing suite with a guest purchase and a corresponding Admin order lookup. Then add the inventory, pricing, and fulfillment scenarios that reflect your business. With plain-English browser cases in testRigor and targeted API or integration checks, teams can verify the parts of their application that customers and merchants depend on.
| Achieve More Than 90% Test Automation | |
| Step by Step Walkthroughs and Help | |
| 14 Day Free Trial, Cancel Anytime |




