Appearance
TEST.assert()
Asserts a condition and logs either a success or failure status message to the test report depending on the result.
If the condition evaluates to false, the test is marked as failed.
Usage
javascript
TEST.assert(condition: boolean, message: string)
TEST.assert(condition: boolean, message: string, errorMessage: string)Parameters
| Parameter | Type | Description |
|---|---|---|
condition | boolean | Condition to validate. This should evaluate to a boolean value. |
message | string | The message to log. This should describe the assertion. |
errorMessage | string | Additional message to log if the condition fails. |
Examples
js
I.click("Add to cart")
var cart = UI.LocalStorage.get("cart")
var cartSize = cart ? cart.items.length : 0
TEST.assert(
cartSize === 10,
"Cart should contain 10 items",
"Cart only contains " + cartSize + " items"
)In this example, the assertion fails if the cart does not contain exactly 10 items, logging a failed step with both messages to the test report.