Class: FakeInstance
Defined in: src/testing/FakeInstance.ts:148
Extended by
Constructors
Constructor
new FakeInstance(options): FakeInstance;Defined in: src/testing/FakeInstance.ts:165
Parameters
| Parameter | Type |
|---|---|
options | FakeInstanceOptions |
Returns
FakeInstance
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
host | readonly | string | - | src/testing/FakeInstance.ts:149 |
origin | readonly | string | - | src/testing/FakeInstance.ts:151 |
software | readonly | object | - | src/testing/FakeInstance.ts:153 |
software.name | public | string | - | src/wellknown.ts:19 |
software.version | public | string | - | src/wellknown.ts:20 |
fetch | readonly | { (input, init?): Promise<Response>; (input, init?): Promise<Response>; } | fetch-compatible adapter. Prefer clientOptions() when constructing a ThreadiverseClient; use this directly to install a global fetch mock. Unrouted requests and { abort } responses throw TypeError, like a real network failure. | src/testing/FakeInstance.ts:218 |
Methods
calls()
calls(matcher): RecordedCall[];Defined in: src/testing/FakeInstance.ts:189
All recorded requests matching "METHOD /path" (query ignored).
Parameters
| Parameter | Type |
|---|---|
matcher | | `POST /${string}` | `DELETE /${string}` | `GET /${string}` | `PUT /${string}` |
Returns
clientOptions()
clientOptions(): ThreadiverseClientOptions;Defined in: src/testing/FakeInstance.ts:205
Options for a ThreadiverseClient scoped to this fake: routes fetch through the instance and isolates software discovery from the process-global cache (so multiple fakes for the same host — e.g. different versions across tests — can't contaminate each other).
const client = new ThreadiverseClient(fake.origin, fake.clientOptions());Returns
handle()
handle(request): Promise<FakeResponse | undefined>;Defined in: src/testing/FakeInstance.ts:252
Resolve a request against the route table.
Returns undefined for requests to other origins (callers decide whether to pass those through). Unmocked same-origin requests are answered with a loud 404 instead of escaping to the real network.
Parameters
| Parameter | Type |
|---|---|
request | FakeRequest |
Returns
Promise<FakeResponse | undefined>
install()
install(page): Promise<void>;Defined in: src/testing/FakeInstance.ts:290
Install onto a Playwright page. Routes all traffic for this instance's origin; other origins are untouched.
Parameters
| Parameter | Type |
|---|---|
page | PageLike |
Returns
Promise<void>
mock()
mock(matcher, responder): void;Defined in: src/testing/FakeInstance.ts:317
Set (or replace) the response for an endpoint. Last call wins.
Parameters
| Parameter | Type |
|---|---|
matcher | | `POST /${string}` | `DELETE /${string}` | `GET /${string}` | `PUT /${string}` |
responder | Responder |
Returns
void
mockOnce()
mockOnce(matcher, responder): void;Defined in: src/testing/FakeInstance.ts:322
Respond once for an endpoint, then fall back to the standing mock.
Parameters
| Parameter | Type |
|---|---|
matcher | | `POST /${string}` | `DELETE /${string}` | `GET /${string}` | `PUT /${string}` |
responder | Responder |
Returns
void
waitForCall()
waitForCall(
matcher,
predicate?,
__namedParameters?): Promise<RecordedCall>;Defined in: src/testing/FakeInstance.ts:333
Wait until a matching request is recorded, then return the latest. Resolution is push-based (no polling), so pending waiters settle the moment the request lands — only the timeout path needs real timers.
Parameters
| Parameter | Type |
|---|---|
matcher | | `POST /${string}` | `DELETE /${string}` | `GET /${string}` | `PUT /${string}` |
predicate | (call) => boolean |
__namedParameters | { timeoutMs?: number; } |
__namedParameters.timeoutMs? | number |
Returns
Promise<RecordedCall>
buildOperationApi()
protected buildOperationApi<Ops>(operations, renderError): OperationApi<Ops>;Defined in: src/testing/FakeInstance.ts:368
Build the operation-level API (on/once/callsTo/waitForPayload) from a provider's operation definitions plus its error wire renderer.
Type Parameters
| Type Parameter |
|---|
Ops extends Record<string, OperationDef<unknown>> |
Parameters
| Parameter | Type |
|---|---|
operations | Ops |
renderError | (error) => FakeResponse |
Returns
OperationApi<Ops>
