Skip to content

testing

Written for test code — asserting what a service was asked to do, or awaiting what it does.

NameCategoryDescription
waitForServiceEvent
utils

Wait for a service event to fire and resolve with the emitted record. Useful in tests to await the result of an asynchronous service event, a bit like promisify for Feathers events.

Curried: bind the app (and optional defaults) once, then call the returned function per service/event. Resolves with a [data, { event, context }] tuple: data is typed as the service's record type, and event is the union of the requested events.

Feathers emits events as emit(event, record, context) and fires one event per record, so each resolution carries a single record and its HookContext.

recordHooks
testing

Record every call that passes through a service or an application, so a test can assert what was requested — and how often — without standing up a spy per method.

Pass an app to record all of its services, or a single service to record just that one; path, method and type narrow it further. The typical use is proving a cache, a debounce or a local-first store did not go to the server, which is awkward to assert on results alone.

The record is indexed by hook type and method — calls.before.get — and every entry is a plain array, so it composes with any predicate, isContext included. So do reset() and waitFor().

By default the live HookContext is recorded. That object keeps mutating as the call travels through the remaining hooks, so if you assert on data or params.query after the call resolved, pass snapshot: true.

See all tags for the full vocabulary.

Released under the MIT License.