runCartAdapterContract
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
function runCartAdapterContract(opts: RunCartAdapterContractOpts): void;Parameters
| Name | Type | Description |
|---|---|---|
opts | RunCartAdapterContractOpts |
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(),
});Related
RunCartAdapterContractOpts CartCapabilityUnsupportedError CartError CartNotFoundError CartProviderError CartUserError CartAdapter CartEventBus
RunCartAdapterContractOpts
Options accepted by . Passed once per adapter under test; the suite name and factory are the only inputs the contract runner needs from the host test file.
SubmitMutation
Serveraction signature that transport layers (Next.js, Remix, tRPC) implement to accept a from the client and return a . Wires the kernel into the framework's a