runCartAdapterContract

cart · /core·function

Vitest-bound contract suite that every implementation must pass. Hosts call this once per adapter at import time inside a *.test.ts file; the suite registers describe + it blocks named after opts.name.

Assertions intentionally exercise externally observable behavior only — capability-method coupling, lifecycle round-trips, error name (not class identity, since errors can cross package boundaries), money shape, custom mutation completeness, and a soft idempotency check. Adapters MAY layer stricter dedup on top.

Signature

@nordcom/commerce-cart

Parameters

NameTypeDescription
optsRunCartAdapterContractOpts

Example

// In my-adapter.test.ts:
import { runCartAdapterContract } from '@nordcom/cart-core/contract-tests';
import { createMockCartAdapter } from '@nordcom/cart-core/mock-adapter';

runCartAdapterContract({
  name: 'mock',
  factory: () => createMockCartAdapter(),
});

RunCartAdapterContractOpts CartCapabilityUnsupportedError CartError CartNotFoundError CartProviderError CartUserError CartAdapter CartEventBus

On this page