Is there a way to create an appropriate matcher in pacts (javascript version, consumer site) for an api endpoint that returns an array of a sum type?
For example, consider the scenario where we have the endpoint /api/events
that gives back a list of dictionaries representing different types of events. Let's say there are two distinct event types:
interface ContentAddedEvent {
type: "ContentAdded"
newContent: string
}
interface UserRegisteredEvent {
type: "Userregistered"
username: string
}
type Event = ContentAddedEvent | UserRegisteredEvent
The endpoint /api/events
retrieves an array of the type Event[]
. How can a suitable matcher be crafted for this situation? I couldn't find a clear example on guiding me through it...