Skip to content

Class: FakeLemmyV1Instance

Defined in: src/testing/lemmyv1/index.ts:224

FakeInstance for Lemmy v1 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 });
fake.seed.loggedInAs(alex);

Derived: site, post list/detail, comment list (honoring parent_id and max_depth), search, community, person (+ person content), account, unread counts, notifications, modlog, and the vote/save/create/edit/ delete/mark-read writes (which mutate the store). Lists paginate with opaque page_cursor strings, like the real server. Use mock() for error injection or endpoints outside this set, and calls() / waitForCall() to assert on outgoing requests. Wire-level builders stay available on build.

Extends

Constructors

Constructor

ts
new FakeLemmyV1Instance(__namedParameters?): FakeLemmyV1Instance;

Defined in: src/testing/lemmyv1/index.ts:245

Parameters

ParameterType
__namedParametersFakeLemmyV1InstanceOptions

Returns

FakeLemmyV1Instance

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/lemmyv1/index.ts:226
build.commentNotificationpublic(over) => object--src/testing/lemmyv1/builders.ts:571
build.commentViewpublic(over) => object--src/testing/lemmyv1/builders.ts:572
build.communitypublic(over) => object--src/testing/lemmyv1/builders.ts:573
build.communityResponsepublic(over) => object--src/testing/lemmyv1/builders.ts:574
build.communityViewpublic(over) => object--src/testing/lemmyv1/builders.ts:575
build.getSiteResponsepublic(over) => object--src/testing/lemmyv1/builders.ts:576
build.localUserpublic(over) => object--src/testing/lemmyv1/builders.ts:577
build.modlogViewpublic(over) => object--src/testing/lemmyv1/builders.ts:578
build.myUserInfopublic(over) => object--src/testing/lemmyv1/builders.ts:579
build.pagedResponsepublic<T>(items, nextPage) => object--src/testing/lemmyv1/builders.ts:580
build.personpublic(over) => object--src/testing/lemmyv1/builders.ts:581
build.personResponsepublic(subject) => object--src/testing/lemmyv1/builders.ts:582
build.personViewpublic(subject) => object--src/testing/lemmyv1/builders.ts:583
build.postpublic(over) => object--src/testing/lemmyv1/builders.ts:584
build.postResponsepublic(view) => object--src/testing/lemmyv1/builders.ts:585
build.postViewpublic(over) => object--src/testing/lemmyv1/builders.ts:586
build.privateMessageNotificationpublic(over) => object--src/testing/lemmyv1/builders.ts:587
build.privateMessageViewpublic(over) => object--src/testing/lemmyv1/builders.ts:588
build.searchResponsepublic(over) => object--src/testing/lemmyv1/builders.ts:589
callsToreadonly<Operation>(operation) => PayloadOf<object[Operation]>[]Canonical payloads of the requests an operation received-src/testing/lemmyv1/index.ts:229
onreadonlyobjectOverride an operation's response (canonical { error } supported)-src/testing/lemmyv1/index.ts:232
on.createCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:55
on.createPostpublic(responder) => void--src/testing/lemmyv1/index.ts:59
on.createPrivateMessagepublic(responder) => void--src/testing/lemmyv1/index.ts:60
on.deleteCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:64
on.deletePostpublic(responder) => void--src/testing/lemmyv1/index.ts:68
on.editCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:69
on.editPostpublic(responder) => void--src/testing/lemmyv1/index.ts:70
on.followCommunitypublic(responder) => void--src/testing/lemmyv1/index.ts:71
on.getCommentspublic(responder) => void--src/testing/lemmyv1/index.ts:75
on.getCommunitypublic(responder) => void--src/testing/lemmyv1/index.ts:89
on.getModlogpublic(responder) => void--src/testing/lemmyv1/index.ts:95
on.getNotificationspublic(responder) => void--src/testing/lemmyv1/index.ts:96
on.getPersonDetailspublic(responder) => void--src/testing/lemmyv1/index.ts:107
on.getPostpublic(responder) => void--src/testing/lemmyv1/index.ts:113
on.getPostspublic(responder) => void--src/testing/lemmyv1/index.ts:119
on.getRandomCommunitypublic(responder) => void--src/testing/lemmyv1/index.ts:133
on.getSitepublic(responder) => void--src/testing/lemmyv1/index.ts:134
on.getSiteMetadatapublic(responder) => void--src/testing/lemmyv1/index.ts:135
on.getUnreadCountpublic(responder) => void--src/testing/lemmyv1/index.ts:141
on.likeCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:142
on.likePostpublic(responder) => void--src/testing/lemmyv1/index.ts:146
on.listPersonContentpublic(responder) => void--src/testing/lemmyv1/index.ts:147
on.loginpublic(responder) => void--src/testing/lemmyv1/index.ts:153
on.markAllAsReadpublic(responder) => void--src/testing/lemmyv1/index.ts:154
on.markNotificationAsReadpublic(responder) => void--src/testing/lemmyv1/index.ts:157
on.markPostAsReadpublic(responder) => void--src/testing/lemmyv1/index.ts:162
on.resolveObjectpublic(responder) => void--src/testing/lemmyv1/index.ts:166
on.saveCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:172
on.savePostpublic(responder) => void--src/testing/lemmyv1/index.ts:176
on.searchpublic(responder) => void--src/testing/lemmyv1/index.ts:177
oncereadonlyobjectOverride an operation's next response only, then fall back-src/testing/lemmyv1/index.ts:235
once.createCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:55
once.createPostpublic(responder) => void--src/testing/lemmyv1/index.ts:59
once.createPrivateMessagepublic(responder) => void--src/testing/lemmyv1/index.ts:60
once.deleteCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:64
once.deletePostpublic(responder) => void--src/testing/lemmyv1/index.ts:68
once.editCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:69
once.editPostpublic(responder) => void--src/testing/lemmyv1/index.ts:70
once.followCommunitypublic(responder) => void--src/testing/lemmyv1/index.ts:71
once.getCommentspublic(responder) => void--src/testing/lemmyv1/index.ts:75
once.getCommunitypublic(responder) => void--src/testing/lemmyv1/index.ts:89
once.getModlogpublic(responder) => void--src/testing/lemmyv1/index.ts:95
once.getNotificationspublic(responder) => void--src/testing/lemmyv1/index.ts:96
once.getPersonDetailspublic(responder) => void--src/testing/lemmyv1/index.ts:107
once.getPostpublic(responder) => void--src/testing/lemmyv1/index.ts:113
once.getPostspublic(responder) => void--src/testing/lemmyv1/index.ts:119
once.getRandomCommunitypublic(responder) => void--src/testing/lemmyv1/index.ts:133
once.getSitepublic(responder) => void--src/testing/lemmyv1/index.ts:134
once.getSiteMetadatapublic(responder) => void--src/testing/lemmyv1/index.ts:135
once.getUnreadCountpublic(responder) => void--src/testing/lemmyv1/index.ts:141
once.likeCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:142
once.likePostpublic(responder) => void--src/testing/lemmyv1/index.ts:146
once.listPersonContentpublic(responder) => void--src/testing/lemmyv1/index.ts:147
once.loginpublic(responder) => void--src/testing/lemmyv1/index.ts:153
once.markAllAsReadpublic(responder) => void--src/testing/lemmyv1/index.ts:154
once.markNotificationAsReadpublic(responder) => void--src/testing/lemmyv1/index.ts:157
once.markPostAsReadpublic(responder) => void--src/testing/lemmyv1/index.ts:162
once.resolveObjectpublic(responder) => void--src/testing/lemmyv1/index.ts:166
once.saveCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:172
once.savePostpublic(responder) => void--src/testing/lemmyv1/index.ts:176
once.searchpublic(responder) => void--src/testing/lemmyv1/index.ts:177
seedreadonlySeedStoreSemantic content store the default routes are derived from-src/testing/lemmyv1/index.ts:238
waitForPayloadreadonly<Operation>(operation, predicate?, options?) => Promise<PayloadOf<object[Operation]>>Wait for an operation's next request; resolves its canonical payload-src/testing/lemmyv1/index.ts:241

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