typescript-testinglisted
Install: claude install-skill MuHamza30/paypal-api-plugin
# Testing code that uses an APIMatic TypeScript SDK
The SDK has **no mocking helpers**. Its transport is an axios client
(`@apimatic/axios-client-adapter`), and the only injection point exposed on `Configuration` is
**`unstable_httpClientOptions`** — passed straight through to that adapter as its axios config. Supplying
a stub **axios adapter** there is the in-process seam: no network, no global patching.
> `unstable_` means exactly that: it is an escape hatch, not a stable API, and may change between SDK
> versions. If you would rather not depend on it, stub at the HTTP layer with `nock` (Node) or `msw`
> instead — the assertions below apply either way.
The samples below use Jest `test` + `expect` for reference only — mirror whatever the project already
uses.
## A reusable stub helper
```typescript
import { Client } from 'paypal-server-sdklib';
function clientReturning(status: number, body: unknown): {
client: Client;
requests: () => any[];
} {
const requests: any[] = [];
const client = new Client({
// Dummy credentials for whatever scheme the operation requires. Auth is applied BEFORE the
// transport, so an unauthenticated stub client throws instead of reaching your adapter.
// Copy the property name and its inner field names from the `Configuration` interface in
// src/configuration.ts; prefer an API-key/basic scheme over an OAuth one.
{apiKeyProperty}: { /* dummy values */ },
unstable_httpClientOptions: {
// An axios adapter: