Skip to main content

EVENT

Expect an event to be published by your services. You can learn more about how to publish an event by referring to our documentation on Events.

info

When viewing test results in both the Tesmon CLI and UI, the eventBody will be masked with "***" to protect the sensitive data. Please note that Tesmon never stores actual data in its cloud and only uses it for processing within the Test run engine in the customer's environment. The actual data is discarded after processing to ensure that it remains secure and private.

Properties

PropertyDescriptionTypeRequired
keyUnique key for the eventstringtrue
withinTime limit in milliseconds for the event to occur from the test start time. Defaults to 3000ms.long

Output

📝 Note: Can be accessed using context["last_output"]

KeyDescriptionType
eventEvent propertiesobject
timeTakenTime taken, in millisecondslong
errorError message, if the event does not arrive within the specified timestring

Example

eventTests.yml
tests:
expectEventTest:
tasks:
- id: task1
expect: expects.expectEvent
validate: scripts.validateEvent

expects:
expectEvent:
type: HTTP::EVENT
props:
key: <event_key>
within: <time_in_ms>

scripts:
validateEvent: assert context["last_output"]["event"]["value"]["<key>"] == "<value>"

Example output

{
"event": {
"id": "2f5da104-ef67-4f55-b821-227f9a12c908",
"key": "EVENT_1",
"value": {
"key1": "value1",
"key2": "value2"
},
"createdAt": "2024-04-17T11:48:43.000Z"
},
"timeTaken": 1031
}