Testing Eventicle Components and Systems

Testing event systems is essential, as their interactions are asynchronous and oftentimes with an implicit, or "choreographed" behaviour.

Eventicle is designed to be easy to test, and each type of component has an idiomatic approach for testing it.

consumeFullEventLog - Check event stream consistency

A common requirement when building event log based systems is to ensure that once an operation or workflow has completed, that the log is in an expected consistent state.

This can be verified in testing using the consumeFullEventLog function.

// ... perform an operation/ workflow that emit events
let events = await consumeFullEventLog("user")

// verify that the event types we expect are in the log, in the right order, and there aren't any extra events
// or duplicates present, here with Jest expectations. Insert assertion library of your choice.

expect(events.map(value => value.type)).toStrictEqual([
  "user.created",
  "user.password_set",
  "user.approved",
  "user.account_locked",
]);

Unit Tests: Commands

Unit Tests: Aggregate Roots

Unit Tests: Sagas

Integration Tests