> ## Documentation Index
> Fetch the complete documentation index at: https://docs.praxa.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Test an SDK integration

> Test Praxa SDK contract metadata, request construction, errors, event resumption, and authenticated runtime behavior.

The SDK accepts a custom <code>fetch</code> implementation. Use it to test
request construction without network access, then run a separate authenticated
canary against the Gateway you intend to operate.

```typescript theme={null}
import {
  PraxaClient,
  PRAXA_CONTRACT_VERSION,
  PRAXA_OPENAPI_SHA256,
} from "@praxa/sdk";
import { strict as assert } from "node:assert";

const requests: Request[] = [];

const client = new PraxaClient({
  baseUrl: "https://gateway.example.test",
  accessToken: () => "test-token",
  fetch: async (input, init) => {
    const request = new Request(input, init);
    requests.push(request);

    return new Response(
      JSON.stringify({
        type: "https://praxa.example/problems/not-implemented",
        title: "Test fixture",
        status: 501,
      }),
      {
        status: 501,
        headers: { "content-type": "application/problem+json" },
      },
    );
  },
});

assert.equal(PRAXA_CONTRACT_VERSION, "aura-integration-gateway-v8.1");
assert.equal(
  PRAXA_OPENAPI_SHA256,
  "a9835faa4654246f83c452ae968a569c85be28f93017882e710ca35c10dbbecc",
);

await client.getReferenceCoverage().catch(() => undefined);
assert.equal(requests.length, 1);
assert.equal(requests[0].headers.get("authorization"), "Bearer test-token");
```

## Test layers

| Layer          | What to assert                                                  |
| -------------- | --------------------------------------------------------------- |
| Package        | Clean install, ESM import, version constants, subpath exports   |
| Client         | URL normalization, headers, body, abort signal, error parsing   |
| Events         | Event ordering, duplicate IDs, resume cursor, terminal readback |
| Authentication | Missing, expired, revoked, and wrong-scope tokens               |
| Isolation      | Another tenant or subject cannot be accessed                    |
| Runtime        | Positive mission lifecycle against the intended Gateway         |

## Production verification

Verify each layer independently:

1. **Package:** install the exact public version in a clean project.
2. **Contract:** validate the request, response, scope, and version metadata.
3. **Authentication:** test valid, missing, expired, revoked, and wrong-scope credentials.
4. **Isolation:** prove the caller cannot read or mutate another subject or tenant.
5. **Idempotency:** replay the same logical mutation and then send a digest mismatch.
6. **Lifecycle:** observe the terminal state rather than stopping at admission.
7. **Cleanup:** delete test data and confirm the documented retention boundary.
