asserts
- Assertions
Define a list of assertions to be verified after the step execution.
yaml
- _: Say hi
log: Bonjour, mes amis !
asserts:
- esquie.result.status === "SUCCESS"
- any:
- esquie.result.data.includes("mon ami")
- esquie.result.data.includes("mes amis")
Assertions are evaluated asynchronously after the task execution, and if any of them fails, the task result will be changed to status ERROR
(even if it was initially SUCCESS
).
These are mostly used in testing scenarios, but can also be used to enforce specific conditions or overwrite a step result based on custom logic.
WARNING
Assertions are implicitly templated and thus must not be wrapped again in ${}
.
Logical operators
Three logical operators are supported to combine multiple assertions:
all
(default): all assertions must resolve to a truthy valueany
: at least one assertion must resolve to a truthy value- In a similar way to
Promise.any()
, further assertions are not evaluated as soon as one of them resolves to a truthy value.
- In a similar way to
one
: exactly one assertion must resolve to a truthy value