assertTrue
Assert that a JavaScript expression evaluates to true.
Asserts that a given expression evaluates to a truthy value. A value is truthy (in JavaScript terms) if it is not false, 0, an empty string (""), null, undefined, or NaN.
Syntax
You can use the shorthand approach, providing only the expression, or you can use the condition and label.
- assertTrue: ${value}
# or
- assertTrue:
condition: ${value}
label: Variable 'value' is setParameters
You can provide the expression directly or use the condition and label parameters for more complex assertions.
condition
Expression
The expression to evaluate. The test passes if the expression is truthy.
label
String
An optional message to display when executing the evaluation.
Usage examples
The following examples show how to use the assertTrue command.
Assert a JavaScript expression
This example uses assertTrue to verify that the text content of two separate views is identical. The label states the purpose of the assertion.
Fail a test with a custom message
This example uses the condition and label parameters to intentionally fail a test and provide a descriptive reason.
Related commands
Last updated