skillZs
LIVE SKILL TAGS
>>> LIVE SKILLS INDEX <<<
* OPEN SOURCE *
NO LOGIN, NO TRACKING
REAL INSTALL DATA
← back to all skills
orcaqubits/agentic-commerce-skills-plugins5 installs

medusa-testing

Test Medusa v2 applications — Jest setup, module unit tests, workflow integration tests, API route tests, medusaIntegrationTestRunner, and mock patterns. Use when writing tests for Medusa projects.

How do I install this agent skill?

npx skills add https://github.com/orcaqubits/agentic-commerce-skills-plugins --skill medusa-testing
view source ↗

Is this agent skill safe to install?

  • Gen Agent Trust Hubpass

    The skill provides templates and instructions for testing Medusa v2 applications using Jest and the official Medusa integration test runner. It fetches documentation from the official MedusaJS website and uses standard development tools.

  • Socketpass

    No alerts

  • Snykwarn

    Risk: MEDIUM · 1 issue

What does this agent skill do?

Medusa v2 Testing

Before writing code

Fetch live docs:

  1. Web-search site:docs.medusajs.com testing for official testing guide and setup
  2. Web-search site:docs.medusajs.com medusaIntegrationTestRunner for integration test utilities
  3. Web-search site:docs.medusajs.com unit test module for module unit testing patterns
  4. Fetch https://docs.medusajs.com/resources/medusa-testing and review test runner configuration
  5. Web-search medusajs v2 jest test workflow 2026 for latest workflow testing patterns

Test Architecture

Test Pyramid

        ┌─────────┐
        │  E2E    │  API route tests (slow, high confidence)
        ├─────────┤
        │ Integr. │  Workflow + cross-module tests
        ├─────────┤
        │  Unit   │  Module service + utility tests (fast)
        └─────────┘

Test Types

TypeScopeRunnerSpeed
UnitSingle module serviceJestFast
IntegrationWorkflows, cross-modulemedusaIntegrationTestRunnerMedium
API RouteHTTP endpointsmedusaIntegrationTestRunner + supertestSlow
E2EFull user flowsPlaywright/Cypress (optional)Slowest

Jest Setup

// Skeleton: jest.config.ts for Medusa v2
// Fetch live docs for current recommended config
module.exports = {
  preset: "ts-jest",
  testEnvironment: "node",
  // Fetch live docs for moduleNameMapper and transform
}

Package Dependencies

PackagePurpose
jestTest runner
ts-jestTypeScript support
@medusajs/test-utilsMedusa test utilities
supertestHTTP assertion library

Fetch live docs for the current @medusajs/test-utils package exports and version compatibility.

Module Unit Tests

// Skeleton: module unit test
// Fetch live docs for module test setup
describe("ProductModuleService", () => {
  let service: IProductModuleService
  // Fetch live docs for beforeAll setup with test database
})

Service Method Testing

Test TargetWhat to Verify
createProductsReturns product with correct fields
listProductsFilters, pagination, sorting work
retrieveProductRelations loaded correctly
updateProductsPartial updates applied
deleteProductsCascade behavior correct

Setup and Teardown

HookPurpose
beforeAllInitialize module with test database
beforeEachSeed test data
afterEachClean up created records
afterAllClose database connection

Fetch live docs for test database initialization and module container setup.

Integration Tests with medusaIntegrationTestRunner

medusaIntegrationTestRunner provides a full Medusa application container with all modules, test database setup/teardown, API client, and seeded admin user.

// Skeleton: integration test — Fetch live docs for config
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"

medusaIntegrationTestRunner({
  testSuite: ({ api, getContainer }) => {
    // Fetch live docs for api and container usage
  },
})

Runner Context

PropertyDescription
apiPre-configured HTTP client (AxiosInstance)
getContainerReturns the DI container for resolving services
dbConnectionDatabase connection reference
modulesConfigOverride module configurations (runner option)

Fetch live docs for the full context object shape and available helper methods.

Workflow Tests

What to Test

AspectVerification
Success pathWorkflow completes, returns expected result
Side effectsLinked modules updated (pricing, inventory)
CompensationFailed step triggers rollback of previous steps
Input validationInvalid inputs produce expected errors
IdempotencyRepeated execution does not create duplicates

Compensation Testing

StrategyDescription
Force step failureMock a step to throw an error
Verify rollbackCheck that previous steps are compensated
Check data stateEnsure database is clean after rollback

Fetch live docs for workflow step mocking and compensation test patterns.

API Route Tests

Route Test Checklist

CheckDescription
Status codeCorrect HTTP status for success and error
Response bodyExpected fields present with correct types
Side effectsDatabase state updated correctly
AuthenticationUnauthenticated requests rejected
ValidationInvalid inputs return 400 with errors
PaginationList endpoints paginate correctly

Authentication in Tests

ActorHeaderSource
AdminAuthorization: Bearer <jwt>Login via /auth/user/emailpass
CustomerAuthorization: Bearer <jwt>Login via /auth/customer/emailpass
Store APIx-publishable-api-keyCreated in test setup

Mock Patterns

PatternWhen to Use
Full module mockUnit testing code that depends on a module
Service method stubOverride specific method behavior
Test databaseIntegration tests with real data

Common Mocks

Mock TargetPurpose
Payment providerAvoid real payment calls in tests
Fulfillment providerAvoid real shipping API calls
Email serviceCapture sent emails for assertion
Event busCapture emitted events for assertion

Fetch live docs for recommended mock patterns and test utility helpers.

Best Practices

Test Organization

  • Co-locate tests with source: src/modules/product/__tests__/
  • Name test files with .spec.ts suffix; group by feature, not test type
  • Use factory functions to generate test data — avoid hardcoded fixtures

Test Data and Integration

  • Use medusaIntegrationTestRunner for all cross-module tests
  • Always test compensation (rollback) paths for critical workflows
  • Clean up in afterEach to prevent pollution; seed minimal data

CI/CD and Coverage

  • Run unit tests on every commit, integration tests on PR; target 80% coverage
  • Use a dedicated test database — never test against production

Fetch the Medusa v2 testing documentation and @medusajs/test-utils reference for exact runner configuration, mock patterns, and test utility APIs before implementing.

Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.

<a href="https://skillzs.dev/skills/orcaqubits/agentic-commerce-skills-plugins/medusa-testing">View medusa-testing on skillZs</a>