Track output events.
This is one of the nullability patterns from James Shore's article on testing without mocks.
Example implementation of an event store:
async record(event) { // ... this.dispatchEvent(new CustomEvent("eventRecorded", { detail: event }));}trackEventsRecorded() { return new OutputTracker(this, "eventRecorded");} Copy
async record(event) { // ... this.dispatchEvent(new CustomEvent("eventRecorded", { detail: event }));}trackEventsRecorded() { return new OutputTracker(this, "eventRecorded");}
Example usage:
const eventsRecorded = eventStore.trackEventsRecorded();// ...const data = eventsRecorded.data(); // [event1, event2, ...] Copy
const eventsRecorded = eventStore.trackEventsRecorded();// ...const data = eventsRecorded.data(); // [event1, event2, ...]
Create a tracker for a specific event of an event target.
The target to track.
The event name to track.
Return the tracked data.
The tracked data.
Clear the tracked data and return the cleared data.
The cleared data.
Stop tracking.
Static
Track output events.
This is one of the nullability patterns from James Shore's article on testing without mocks.
Example implementation of an event store:
Example usage: