Remote / foldkit-remote-domain

Test a page against an in-memory Domain model

foldkit-remote-domain/testing hosts your Domain model in memory with View deliveries paused until you call drain, letting client tests exercise real aggregates and lagging Views with no HTTP server:

ts
import { REMOTE_PROTOCOL_VERSION, RemoteClient } from 'foldkit-remote'
import { Fixture } from 'foldkit-remote-domain/testing'

const shop = Fixture.make(NotesApi, {
  model: Notes,
  given: [{ aggregate: 'Note', id: 'n1', events: [new Renamed({ name: 'Draft', revision: 1 })] }],
  bindings: { views: [NoteReads], commands: [RenameBinding], denied: () => 'Unauthenticated' },
})

const read = Effect.gen(function* () {
  yield* shop.drain
  const client = yield* RemoteClient
  return yield* client.read({
    version: REMOTE_PROTOCOL_VERSION,
    requests: [{ entity: 'Note', id: 'n1', fields: ['name', 'revision'] }],
  })
}).pipe(Effect.provide(shop.layer))
  • shop.layer provides both RemoteClient and the Api client.
  • shop.commits() lists Events committed by commands (excluding seeded given events).
  • shop.as, headers, middleware, handlers, and through let tests simulate signed-in actors, dropped replies, and out-of-order deliveries.

Note that given seeds events through Domain's internal Model.Internals helper, which may change across beta releases.