Skip to content

Class: FakePiefedInstance

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

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 (honoring parent_id and max_depth), search, community, person, unread counts, the notification fan-out (replies/mentions/private messages), and the vote/save/create/ edit/delete/mark-read writes (which mutate the store). Lists paginate by 1-based page number, like the real server. 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:290

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:24
software.versionpublicstring--src/wellknown.ts:25
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:230
buildreadonlyobjectWire-format builders bound to this instance's host-src/testing/piefed/index.ts:271
build.commentListResponsepublic(comments, nextPage) => object--src/testing/piefed/builders.ts:441
build.commentReplyViewpublic(over) => object--src/testing/piefed/builders.ts:442
build.commentViewpublic(over) => object--src/testing/piefed/builders.ts:443
build.communitypublic(over) => object--src/testing/piefed/builders.ts:444
build.communityResponsepublic(over) => object--src/testing/piefed/builders.ts:445
build.communityViewpublic(over) => object--src/testing/piefed/builders.ts:446
build.getSiteResponsepublic(over) => object--src/testing/piefed/builders.ts:447
build.localUserpublic() => object--src/testing/piefed/builders.ts:448
build.myUserInfopublic(subject) => object--src/testing/piefed/builders.ts:449
build.personpublic(over) => object--src/testing/piefed/builders.ts:450
build.personViewpublic(subject) => object--src/testing/piefed/builders.ts:451
build.postpublic(over) => object--src/testing/piefed/builders.ts:452
build.postListResponsepublic(posts, nextPage) => object--src/testing/piefed/builders.ts:453
build.postViewpublic(over) => object--src/testing/piefed/builders.ts:454
build.privateMessageListResponsepublic(private_messages) => object--src/testing/piefed/builders.ts:455
build.privateMessageViewpublic(over) => object--src/testing/piefed/builders.ts:456
build.repliesResponsepublic(replies, nextPage) => object--src/testing/piefed/builders.ts:457
build.searchResponsepublic(over) => object--src/testing/piefed/builders.ts:458
build.userResponsepublic(subject) => object--src/testing/piefed/builders.ts:459
callsToreadonly<Operation>(operation) => PayloadOf<object[Operation]>[]Canonical payloads of the requests an operation received-src/testing/piefed/index.ts:274
onreadonlyobjectOverride an operation's response (canonical { error } supported)-src/testing/piefed/index.ts:277
on.createCommentpublic(responder) => void--src/testing/piefed/index.ts:65
on.createPostpublic(responder) => void--src/testing/piefed/index.ts:73
on.createPrivateMessagepublic(responder) => void--src/testing/piefed/index.ts:82
on.deleteCommentpublic(responder) => void--src/testing/piefed/index.ts:86
on.deletePostpublic(responder) => void--src/testing/piefed/index.ts:90
on.editCommentpublic(responder) => void--src/testing/piefed/index.ts:94
on.editPostpublic(responder) => void--src/testing/piefed/index.ts:102
on.followCommunitypublic(responder) => void--src/testing/piefed/index.ts:111
on.getCommentspublic(responder) => void--src/testing/piefed/index.ts:115
on.getCommunitypublic(responder) => void--src/testing/piefed/index.ts:138
on.getPersonDetailspublic(responder) => void--src/testing/piefed/index.ts:144
on.getPostpublic(responder) => void--src/testing/piefed/index.ts:150
on.getPostspublic(responder) => void--src/testing/piefed/index.ts:156
on.getSitepublic(responder) => void--src/testing/piefed/index.ts:171
on.getUnreadCountpublic(responder) => void--src/testing/piefed/index.ts:172
on.likeCommentpublic(responder) => void--src/testing/piefed/index.ts:173
on.likePostpublic(responder) => void--src/testing/piefed/index.ts:180
on.loginpublic(responder) => void--src/testing/piefed/index.ts:187
on.markAllAsReadpublic(responder) => void--src/testing/piefed/index.ts:194
on.markPostAsReadpublic(responder) => void--src/testing/piefed/index.ts:197
on.resolveObjectpublic(responder) => void--src/testing/piefed/index.ts:201
on.saveCommentpublic(responder) => void--src/testing/piefed/index.ts:207
on.savePostpublic(responder) => void--src/testing/piefed/index.ts:211
on.searchpublic(responder) => void--src/testing/piefed/index.ts:212
oncereadonlyobjectOverride an operation's next response only, then fall back-src/testing/piefed/index.ts:280
once.createCommentpublic(responder) => void--src/testing/piefed/index.ts:65
once.createPostpublic(responder) => void--src/testing/piefed/index.ts:73
once.createPrivateMessagepublic(responder) => void--src/testing/piefed/index.ts:82
once.deleteCommentpublic(responder) => void--src/testing/piefed/index.ts:86
once.deletePostpublic(responder) => void--src/testing/piefed/index.ts:90
once.editCommentpublic(responder) => void--src/testing/piefed/index.ts:94
once.editPostpublic(responder) => void--src/testing/piefed/index.ts:102
once.followCommunitypublic(responder) => void--src/testing/piefed/index.ts:111
once.getCommentspublic(responder) => void--src/testing/piefed/index.ts:115
once.getCommunitypublic(responder) => void--src/testing/piefed/index.ts:138
once.getPersonDetailspublic(responder) => void--src/testing/piefed/index.ts:144
once.getPostpublic(responder) => void--src/testing/piefed/index.ts:150
once.getPostspublic(responder) => void--src/testing/piefed/index.ts:156
once.getSitepublic(responder) => void--src/testing/piefed/index.ts:171
once.getUnreadCountpublic(responder) => void--src/testing/piefed/index.ts:172
once.likeCommentpublic(responder) => void--src/testing/piefed/index.ts:173
once.likePostpublic(responder) => void--src/testing/piefed/index.ts:180
once.loginpublic(responder) => void--src/testing/piefed/index.ts:187
once.markAllAsReadpublic(responder) => void--src/testing/piefed/index.ts:194
once.markPostAsReadpublic(responder) => void--src/testing/piefed/index.ts:197
once.resolveObjectpublic(responder) => void--src/testing/piefed/index.ts:201
once.saveCommentpublic(responder) => void--src/testing/piefed/index.ts:207
once.savePostpublic(responder) => void--src/testing/piefed/index.ts:211
once.searchpublic(responder) => void--src/testing/piefed/index.ts:212
seedreadonlySeedStoreSemantic content store the default routes are derived from-src/testing/piefed/index.ts:283
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:286

Methods

allCalls()

ts
allCalls(): RecordedCall[];

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

Every request this instance received, in order.

For "nothing was sent" claims: asserting a specific route was never called can't fail if the client has no way to call it, whereas comparing this list before and after an action genuinely checks that the action stayed local.

Returns

RecordedCall[]

Inherited from

FakeInstance.allCalls


calls()

ts
calls(matcher): RecordedCall[];

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

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:217

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:264

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:302

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:329

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:334

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:345

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:380

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