Skip to content

Class: FakePiefedInstance

Defined in: src/testing/piefed/index.ts:249

FakeInstance for PieFed whose default routes are derived, per request, from the semantic seed store — tests describe what exists, not which endpoint returns it:

ts
const alex = fake.seed.person({ name: "alex" });
fake.seed.post({ name: "Hello **world**", creator: alex });

Derived: site, post list/detail, comment list, community, person, unread counts, the notification fan-out (replies/mentions/private messages), and mark-as-read writes (which mutate the seed store). Use mock() for error injection or endpoints outside this set. Wire-level builders stay available on build.

Extends

Constructors

Constructor

ts
new FakePiefedInstance(__namedParameters?): FakePiefedInstance;

Defined in: src/testing/piefed/index.ts:270

Parameters

ParameterType
__namedParametersFakePiefedInstanceOptions

Returns

FakePiefedInstance

Overrides

FakeInstance.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
hostreadonlystring-FakeInstance.hostsrc/testing/FakeInstance.ts:149
originreadonlystring-FakeInstance.originsrc/testing/FakeInstance.ts:151
softwarereadonlyobject-FakeInstance.softwaresrc/testing/FakeInstance.ts:153
software.namepublicstring--src/wellknown.ts:19
software.versionpublicstring--src/wellknown.ts:20
fetchreadonly{ (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.FakeInstance.fetchsrc/testing/FakeInstance.ts:218
buildreadonlyobjectWire-format builders bound to this instance's host-src/testing/piefed/index.ts:251
build.commentListResponsepublic(comments, nextPage) => object--src/testing/piefed/builders.ts:357
build.commentReplyViewpublic(over) => object--src/testing/piefed/builders.ts:358
build.commentViewpublic(over) => object--src/testing/piefed/builders.ts:359
build.communitypublic(over) => object--src/testing/piefed/builders.ts:360
build.communityResponsepublic(over) => object--src/testing/piefed/builders.ts:361
build.communityViewpublic(over) => object--src/testing/piefed/builders.ts:362
build.getSiteResponsepublic(over) => object--src/testing/piefed/builders.ts:363
build.personpublic(over) => object--src/testing/piefed/builders.ts:364
build.personViewpublic(subject) => object--src/testing/piefed/builders.ts:365
build.postpublic(over) => object--src/testing/piefed/builders.ts:366
build.postListResponsepublic(posts, nextPage) => object--src/testing/piefed/builders.ts:367
build.postViewpublic(over) => object--src/testing/piefed/builders.ts:368
build.privateMessageListResponsepublic(private_messages) => object--src/testing/piefed/builders.ts:369
build.privateMessageViewpublic(over) => object--src/testing/piefed/builders.ts:370
build.repliesResponsepublic(replies, nextPage) => object--src/testing/piefed/builders.ts:371
build.userResponsepublic(subject) => object--src/testing/piefed/builders.ts:372
callsToreadonly<Operation>(operation) => PayloadOf<object[Operation]>[]Canonical payloads of the requests an operation received-src/testing/piefed/index.ts:254
onreadonlyobjectOverride an operation's response (canonical { error } supported)-src/testing/piefed/index.ts:257
on.createCommentpublic(responder) => void--src/testing/piefed/index.ts:63
on.createPostpublic(responder) => void--src/testing/piefed/index.ts:71
on.createPrivateMessagepublic(responder) => void--src/testing/piefed/index.ts:80
on.deleteCommentpublic(responder) => void--src/testing/piefed/index.ts:84
on.deletePostpublic(responder) => void--src/testing/piefed/index.ts:88
on.editCommentpublic(responder) => void--src/testing/piefed/index.ts:92
on.editPostpublic(responder) => void--src/testing/piefed/index.ts:100
on.followCommunitypublic(responder) => void--src/testing/piefed/index.ts:109
on.getCommentspublic(responder) => void--src/testing/piefed/index.ts:113
on.getCommunitypublic(responder) => void--src/testing/piefed/index.ts:128
on.getPersonDetailspublic(responder) => void--src/testing/piefed/index.ts:134
on.getPostpublic(responder) => void--src/testing/piefed/index.ts:140
on.getPostspublic(responder) => void--src/testing/piefed/index.ts:146
on.getSitepublic(responder) => void--src/testing/piefed/index.ts:161
on.getUnreadCountpublic(responder) => void--src/testing/piefed/index.ts:162
on.likeCommentpublic(responder) => void--src/testing/piefed/index.ts:163
on.likePostpublic(responder) => void--src/testing/piefed/index.ts:170
on.loginpublic(responder) => void--src/testing/piefed/index.ts:177
on.markPostAsReadpublic(responder) => void--src/testing/piefed/index.ts:184
on.resolveObjectpublic(responder) => void--src/testing/piefed/index.ts:188
on.saveCommentpublic(responder) => void--src/testing/piefed/index.ts:194
on.savePostpublic(responder) => void--src/testing/piefed/index.ts:198
on.searchpublic(responder) => void--src/testing/piefed/index.ts:199
oncereadonlyobjectOverride an operation's next response only, then fall back-src/testing/piefed/index.ts:260
once.createCommentpublic(responder) => void--src/testing/piefed/index.ts:63
once.createPostpublic(responder) => void--src/testing/piefed/index.ts:71
once.createPrivateMessagepublic(responder) => void--src/testing/piefed/index.ts:80
once.deleteCommentpublic(responder) => void--src/testing/piefed/index.ts:84
once.deletePostpublic(responder) => void--src/testing/piefed/index.ts:88
once.editCommentpublic(responder) => void--src/testing/piefed/index.ts:92
once.editPostpublic(responder) => void--src/testing/piefed/index.ts:100
once.followCommunitypublic(responder) => void--src/testing/piefed/index.ts:109
once.getCommentspublic(responder) => void--src/testing/piefed/index.ts:113
once.getCommunitypublic(responder) => void--src/testing/piefed/index.ts:128
once.getPersonDetailspublic(responder) => void--src/testing/piefed/index.ts:134
once.getPostpublic(responder) => void--src/testing/piefed/index.ts:140
once.getPostspublic(responder) => void--src/testing/piefed/index.ts:146
once.getSitepublic(responder) => void--src/testing/piefed/index.ts:161
once.getUnreadCountpublic(responder) => void--src/testing/piefed/index.ts:162
once.likeCommentpublic(responder) => void--src/testing/piefed/index.ts:163
once.likePostpublic(responder) => void--src/testing/piefed/index.ts:170
once.loginpublic(responder) => void--src/testing/piefed/index.ts:177
once.markPostAsReadpublic(responder) => void--src/testing/piefed/index.ts:184
once.resolveObjectpublic(responder) => void--src/testing/piefed/index.ts:188
once.saveCommentpublic(responder) => void--src/testing/piefed/index.ts:194
once.savePostpublic(responder) => void--src/testing/piefed/index.ts:198
once.searchpublic(responder) => void--src/testing/piefed/index.ts:199
seedreadonlySeedStoreSemantic content store the default routes are derived from-src/testing/piefed/index.ts:263
waitForPayloadreadonly<Operation>(operation, predicate?, options?) => Promise<PayloadOf<object[Operation]>>Wait for an operation's next request; resolves its canonical payload-src/testing/piefed/index.ts:266

Methods

calls()

ts
calls(matcher): RecordedCall[];

Defined in: src/testing/FakeInstance.ts:189

All recorded requests matching "METHOD /path" (query ignored).

Parameters

ParameterType
matcher| `POST /${string}` | `DELETE /${string}` | `GET /${string}` | `PUT /${string}`

Returns

RecordedCall[]

Inherited from

FakeInstance.calls


clientOptions()

ts
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).

ts
const client = new ThreadiverseClient(fake.origin, fake.clientOptions());

Returns

ThreadiverseClientOptions

Inherited from

FakeInstance.clientOptions


handle()

ts
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

ParameterType
requestFakeRequest

Returns

Promise<FakeResponse | undefined>

Inherited from

FakeInstance.handle


install()

ts
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

ParameterType
pagePageLike

Returns

Promise<void>

Inherited from

FakeInstance.install


mock()

ts
mock(matcher, responder): void;

Defined in: src/testing/FakeInstance.ts:317

Set (or replace) the response for an endpoint. Last call wins.

Parameters

ParameterType
matcher| `POST /${string}` | `DELETE /${string}` | `GET /${string}` | `PUT /${string}`
responderResponder

Returns

void

Inherited from

FakeInstance.mock


mockOnce()

ts
mockOnce(matcher, responder): void;

Defined in: src/testing/FakeInstance.ts:322

Respond once for an endpoint, then fall back to the standing mock.

Parameters

ParameterType
matcher| `POST /${string}` | `DELETE /${string}` | `GET /${string}` | `PUT /${string}`
responderResponder

Returns

void

Inherited from

FakeInstance.mockOnce


waitForCall()

ts
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

ParameterType
matcher| `POST /${string}` | `DELETE /${string}` | `GET /${string}` | `PUT /${string}`
predicate(call) => boolean
__namedParameters{ timeoutMs?: number; }
__namedParameters.timeoutMs?number

Returns

Promise<RecordedCall>

Inherited from

FakeInstance.waitForCall


buildOperationApi()

ts
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

ParameterType
operationsOps
renderError(error) => FakeResponse

Returns

OperationApi<Ops>

Inherited from

FakeInstance.buildOperationApi