Skip to content

Class: FakeLemmyV1Instance

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

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, community, person (+ person content), account, unread counts, notifications, modlog. 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:240

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: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/lemmyv1/index.ts:221
build.commentNotificationpublic(over) => object--src/testing/lemmyv1/builders.ts:513
build.commentViewpublic(over) => object--src/testing/lemmyv1/builders.ts:514
build.communitypublic(over) => object--src/testing/lemmyv1/builders.ts:515
build.communityResponsepublic(over) => object--src/testing/lemmyv1/builders.ts:516
build.communityViewpublic(over) => object--src/testing/lemmyv1/builders.ts:517
build.getSiteResponsepublic(over) => object--src/testing/lemmyv1/builders.ts:518
build.localUserpublic(over) => object--src/testing/lemmyv1/builders.ts:519
build.modlogViewpublic(over) => object--src/testing/lemmyv1/builders.ts:520
build.myUserInfopublic(over) => object--src/testing/lemmyv1/builders.ts:521
build.pagedResponsepublic<T>(items, nextPage) => object--src/testing/lemmyv1/builders.ts:522
build.personpublic(over) => object--src/testing/lemmyv1/builders.ts:523
build.personResponsepublic(subject) => object--src/testing/lemmyv1/builders.ts:524
build.postpublic(over) => object--src/testing/lemmyv1/builders.ts:525
build.postResponsepublic(view) => object--src/testing/lemmyv1/builders.ts:526
build.postViewpublic(over) => object--src/testing/lemmyv1/builders.ts:527
build.privateMessageNotificationpublic(over) => object--src/testing/lemmyv1/builders.ts:528
build.privateMessageViewpublic(over) => object--src/testing/lemmyv1/builders.ts:529
callsToreadonly<Operation>(operation) => PayloadOf<object[Operation]>[]Canonical payloads of the requests an operation received-src/testing/lemmyv1/index.ts:224
onreadonlyobjectOverride an operation's response (canonical { error } supported)-src/testing/lemmyv1/index.ts:227
on.createCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:53
on.createPostpublic(responder) => void--src/testing/lemmyv1/index.ts:57
on.createPrivateMessagepublic(responder) => void--src/testing/lemmyv1/index.ts:58
on.deleteCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:62
on.deletePostpublic(responder) => void--src/testing/lemmyv1/index.ts:66
on.editCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:67
on.editPostpublic(responder) => void--src/testing/lemmyv1/index.ts:68
on.followCommunitypublic(responder) => void--src/testing/lemmyv1/index.ts:69
on.getCommentspublic(responder) => void--src/testing/lemmyv1/index.ts:73
on.getCommunitypublic(responder) => void--src/testing/lemmyv1/index.ts:87
on.getModlogpublic(responder) => void--src/testing/lemmyv1/index.ts:93
on.getNotificationspublic(responder) => void--src/testing/lemmyv1/index.ts:94
on.getPersonDetailspublic(responder) => void--src/testing/lemmyv1/index.ts:105
on.getPostpublic(responder) => void--src/testing/lemmyv1/index.ts:111
on.getPostspublic(responder) => void--src/testing/lemmyv1/index.ts:117
on.getRandomCommunitypublic(responder) => void--src/testing/lemmyv1/index.ts:131
on.getSitepublic(responder) => void--src/testing/lemmyv1/index.ts:132
on.getSiteMetadatapublic(responder) => void--src/testing/lemmyv1/index.ts:133
on.getUnreadCountpublic(responder) => void--src/testing/lemmyv1/index.ts:139
on.likeCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:140
on.likePostpublic(responder) => void--src/testing/lemmyv1/index.ts:144
on.listPersonContentpublic(responder) => void--src/testing/lemmyv1/index.ts:145
on.loginpublic(responder) => void--src/testing/lemmyv1/index.ts:151
on.markAllAsReadpublic(responder) => void--src/testing/lemmyv1/index.ts:152
on.markNotificationAsReadpublic(responder) => void--src/testing/lemmyv1/index.ts:155
on.markPostAsReadpublic(responder) => void--src/testing/lemmyv1/index.ts:160
on.resolveObjectpublic(responder) => void--src/testing/lemmyv1/index.ts:164
on.saveCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:170
on.savePostpublic(responder) => void--src/testing/lemmyv1/index.ts:174
on.searchpublic(responder) => void--src/testing/lemmyv1/index.ts:175
oncereadonlyobjectOverride an operation's next response only, then fall back-src/testing/lemmyv1/index.ts:230
once.createCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:53
once.createPostpublic(responder) => void--src/testing/lemmyv1/index.ts:57
once.createPrivateMessagepublic(responder) => void--src/testing/lemmyv1/index.ts:58
once.deleteCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:62
once.deletePostpublic(responder) => void--src/testing/lemmyv1/index.ts:66
once.editCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:67
once.editPostpublic(responder) => void--src/testing/lemmyv1/index.ts:68
once.followCommunitypublic(responder) => void--src/testing/lemmyv1/index.ts:69
once.getCommentspublic(responder) => void--src/testing/lemmyv1/index.ts:73
once.getCommunitypublic(responder) => void--src/testing/lemmyv1/index.ts:87
once.getModlogpublic(responder) => void--src/testing/lemmyv1/index.ts:93
once.getNotificationspublic(responder) => void--src/testing/lemmyv1/index.ts:94
once.getPersonDetailspublic(responder) => void--src/testing/lemmyv1/index.ts:105
once.getPostpublic(responder) => void--src/testing/lemmyv1/index.ts:111
once.getPostspublic(responder) => void--src/testing/lemmyv1/index.ts:117
once.getRandomCommunitypublic(responder) => void--src/testing/lemmyv1/index.ts:131
once.getSitepublic(responder) => void--src/testing/lemmyv1/index.ts:132
once.getSiteMetadatapublic(responder) => void--src/testing/lemmyv1/index.ts:133
once.getUnreadCountpublic(responder) => void--src/testing/lemmyv1/index.ts:139
once.likeCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:140
once.likePostpublic(responder) => void--src/testing/lemmyv1/index.ts:144
once.listPersonContentpublic(responder) => void--src/testing/lemmyv1/index.ts:145
once.loginpublic(responder) => void--src/testing/lemmyv1/index.ts:151
once.markAllAsReadpublic(responder) => void--src/testing/lemmyv1/index.ts:152
once.markNotificationAsReadpublic(responder) => void--src/testing/lemmyv1/index.ts:155
once.markPostAsReadpublic(responder) => void--src/testing/lemmyv1/index.ts:160
once.resolveObjectpublic(responder) => void--src/testing/lemmyv1/index.ts:164
once.saveCommentpublic(responder) => void--src/testing/lemmyv1/index.ts:170
once.savePostpublic(responder) => void--src/testing/lemmyv1/index.ts:174
once.searchpublic(responder) => void--src/testing/lemmyv1/index.ts:175
seedreadonlySeedStoreSemantic content store the default routes are derived from-src/testing/lemmyv1/index.ts:233
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:236

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