Interactive Commands
/assert
Use the /assert command to ensure specific conditions are met in your tests.
Command: /assert
Description
The /assert
command ensures that a specific condition is true within your test. This is useful for verifying that tasks were completed successfully, just as a user would observe.
Usage
Behavior
- The
/assert
command generates an assertion based on the specified criteria. - TestDriver takes a screenshot and uses it to verify that the condition described in the
expect
field is true. - If the condition isn’t met, the test will fail and exit immediately.
Example usage
Basic assertion
This generates the following command:
Asynchronous assertion
To speed up tests, use async: true
to allow the test to continue without waiting for the assertion to pass:
Protips
- Use assertions sparingly to avoid slowing down your tests.
- Combine
async: true
with assertions to improve test performance while still validating critical conditions. - Ensure the
expect
field clearly describes the condition to avoid ambiguity.
Gotchas
- If the condition in
expect
isn’t met, the test will fail and exit immediately. - Overusing assertions can make tests slower and harder to maintain.
Notes
- The
/assert
command is ideal for validating key checkpoints in your test workflow. - Use this command to ensure that critical tasks, such as error-free execution or successful navigation, are completed as expected.