assertEvents
Assert that the app sent analytics events (Astra Scout only).
Astra Scout only
assertEvents is not a Maestro command. A flow that uses it does not run on plain Maestro. The events come from the Amplitude capture, see Tracking.
The assertEvents command checks that the app sent the analytics events you list. It waits for events that have not arrived yet, up to the timeout.
Which events count
The window opens 500 ms before the last command that acts on the app (a tap, text input, swipe, launchApp, and so on). Commands that only observe or wait (assertVisible, assertTrue, extendedWaitUntil, takeScreenshot, evalScript, other assertEvents, and the like) do not move it. A runFlow, repeat or retry whose commands acted on the app counts as one action that started when the block started: an assertEvents right after it checks every event the block sent, for example the app's first events after a loop that answers permission prompts in whatever order they appear. A block that did nothing (a when that did not match) leaves the window where it was. With no action yet, the window opens at the start of the flow. So tapOn, assertVisible, assertEvents checks the events of the tap.
The wait lasts timeout milliseconds counted from the assertEvents itself, not from the command before it.
One caveat: an event the previous action sent less than 500 ms before the next action started can be counted for the next action.
Each listed event must match exactly one event the app sent: the first one, in time order, with that name and the properties you describe. An event that one assertEvents matched is not matched again by a later one in the same run. The order of the events inside one step does not matter. SDK internal events such as $identify are ignored.
If an event is missing, the step fails and says which one, and the events that did arrive. If an event arrived with the wrong property, the message gives the property and the value received. A failed assertEvents does not stop the flow: the next commands still run, but the run ends failed.
Syntax
- assertEvents: [Onboarding Step Viewed]
- assertEvents:
- License Selected:
license type: car
- assertEvents:
timeout: 8000
events:
- Paywall Viewed: { placement: onboarding }Parameters
| Parameter | Type | Description |
|---|---|---|
events | List | The events to expect. Each is an event name, or a name with a map of properties. |
timeout | Integer | The maximum time to wait for the events, in milliseconds. Defaults to 5000. |
A property value is either a plain value, which must equal the value received, or a map of conditions:
| Condition | Description |
|---|---|
equals | The value must equal this. |
in | The value must be one of this list. |
min | The value must be a number at least this. |
max | The value must be a number at most this. |
regex | The value must be a string that matches this regular expression. |
type | string, boolean, integer or number. |
Usage examples
- tapOn: "Continue"
- assertEvents:
- Onboarding Step Viewed:
step: { in: [1, 2] }
source: { regex: "^onb" }