Signature
Parameters
string
required
A statement about the screen that should be true, such as
'the cart shows 1 item'.AssertOptions
Returns
Promise<boolean>. Resolves to true when the statement is true.
Errors
When the statement is false,assert() throws, so the test fails at that line. The error message starts with AI Assertion failed:, followed by your statement and the AI’s explanation.
Inside ai(), assertions don’t throw. They resolve to false so the AI can keep working.
Examples
Check the result of an action
Check text in a field
Use it with expect()
assert() already fails the test when the statement is false. An expect() makes the check visible to anyone reading the test:
Wait for something before asserting
assert() checks the screen once. For something that takes time to appear, wait for it with find() first:
Complete example
tests/login.test.mjs
Related
- Make assertions: write assertions that catch real regressions
- extract(): read a value off the screen to compare yourself
- find(): wait for an element before asserting
- Caching: how assertion results are reused

