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

# Testing API

> Every export of @tappify/extension-sdk/testing, for component and server tests.

Tests import one entry, and a preset in the test setup:

```ts theme={null}
import { renderWithTap, createTestClient } from "@tappify/extension-sdk/testing";
```

Each symbol's page below is generated from the SDK's own TypeScript declarations. The
walkthrough is on [Testing with the SDK](/extensions/test/testing-with-the-sdk).

## Presets

`@tappify/extension-sdk/testing/vitest` and `@tappify/extension-sdk/testing/jest` are
side-effect modules. Importing one installs the host CSS variables and registers the
matchers.

## Rendering

| Symbol                                                                                     | Is                                                                                                                                     |
| ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
| [`renderWithTap`](/extensions/reference/testing-api/Function.renderWithTap)                | Renders a component against a mock bridge                                                                                              |
| [`RenderWithTapOptions`](/extensions/reference/testing-api/Interface.RenderWithTapOptions) | `mock`, `queryClient`, `container`, plus every `createTapMock` option (`scopes`, `size`, `filters`, `project`, `server`, `handler`, …) |
| [`RenderWithTapResult`](/extensions/reference/testing-api/Interface.RenderWithTapResult)   | Testing Library's result plus the `mock`                                                                                               |

## The mock bridge

| Symbol                                                                                     | Is                                                                                                                                    |
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| [`createTapMock`](/extensions/reference/testing-api/Function.createTapMock)                | The bridge on its own                                                                                                                 |
| [`TapMock`](/extensions/reference/testing-api/Interface.TapMock)                           | `tap`, `calls`, `portal`, `documents`, `emit`, `setFilters`, `setSize`, `setTheme`, `setParams`                                       |
| [`TapMockCalls`](/extensions/reference/testing-api/Interface.TapMockCalls)                 | Everything the component did: navigations, searches, toasts, confirms, actions, telemetry, chats, externals, downloads, copies, cards |
| [`CreateTapMockOptions`](/extensions/reference/testing-api/Interface.CreateTapMockOptions) | The same options `renderWithTap` takes                                                                                                |

## Matchers

[`tapMatchers`](/extensions/reference/testing-api/Variable.tapMatchers) and
[`registerTapMatchers`](/extensions/reference/testing-api/Function.registerTapMatchers). The
presets register them for you. Each one takes a
[`MatcherTarget`](/extensions/reference/testing-api/Interface.MatcherTarget) and returns a
[`MatcherResult`](/extensions/reference/testing-api/Interface.MatcherResult).

| Matcher                              | Passes when                                            |
| ------------------------------------ | ------------------------------------------------------ |
| `toHaveNavigatedTo(path)`            | The component navigated there                          |
| `toHaveToasted(message)`             | A toast matched, exactly or by pattern                 |
| `toHaveRunAction(id, input?)`        | An action ran with that input                          |
| `toHaveStored(collection, document)` | A document deep-equal to that one is in the collection |

## Testing your server

| Symbol                                                                                 | Is                                                                                               |
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| [`createTestClient`](/extensions/reference/testing-api/Function.createTestClient)      | Drives a handler the way Tappify does                                                            |
| [`TestClient`](/extensions/reference/testing-api/Interface.TestClient)                 | `health`, `metrics`, `tool`, `mention`, `action`, `procedure`, `context`, `event`, `work`, `raw` |
| [`TestClientDefaults`](/extensions/reference/testing-api/Interface.TestClientDefaults) | `install`, `scopes`, `credentials`, `documents`, `filters`, `eventId`, `origin`                  |
| [`signTestToken`](/extensions/reference/testing-api/Function.signTestToken)            | A signed install token for a test                                                                |
| [`testJwks`](/extensions/reference/testing-api/Function.testJwks)                      | The matching key set                                                                             |

## Validators

[`validateMetricsResponse`](/extensions/reference/testing-api/Function.validateMetricsResponse)
checks a metrics response against your declared metric definitions;
[`validateToolResponse`](/extensions/reference/testing-api/Function.validateToolResponse)
checks a tool result against its declared shape. Both return the problems as strings, so a
test fails the way `doctor` would.

## Fixtures

[`fixtures`](/extensions/reference/testing-api/Variable.fixtures), typed
[`TapFixtures`](/extensions/reference/testing-api/Interface.TapFixtures), is the sandbox data the
portal preview also uses, so a component behaves the same in both. The pieces are
[`fixtureProject`](/extensions/reference/testing-api/Variable.fixtureProject),
[`fixtureApps`](/extensions/reference/testing-api/Variable.fixtureApps),
[`fixtureReleases`](/extensions/reference/testing-api/Variable.fixtureReleases),
[`fixtureKeywords`](/extensions/reference/testing-api/Variable.fixtureKeywords),
[`fixtureListings`](/extensions/reference/testing-api/Variable.fixtureListings),
[`fixtureReviews`](/extensions/reference/testing-api/Variable.fixtureReviews),
[`fixtureCrashes`](/extensions/reference/testing-api/Variable.fixtureCrashes),
[`fixtureRevenue`](/extensions/reference/testing-api/Variable.fixtureRevenue),
[`fixtureSeries`](/extensions/reference/testing-api/Function.fixtureSeries) and
[`answerFixtureQuery`](/extensions/reference/testing-api/Function.answerFixtureQuery).

[`installHostTheme`](/extensions/reference/testing-api/Function.installHostTheme) puts the
host's CSS variables on a root, for a test that renders outside `renderWithTap`.
