Assertions
Assertions verify that your test achieved the expected outcome. They're evaluated by AI using screenshots and page state.
What Are Assertions?
Assertions are statements that should be true after all steps complete:
"User should be logged in"
"Shopping cart should contain 2 items"
"Error message should not be visible"
The AI evaluates each assertion and reports pass/fail with a confidence score.
Adding Assertions
- Open a test case
- Scroll to the Assertions section
- Click Add Assertion
- Enter your assertion text
- Click Save
Writing Effective Assertions
Be Specific
❌ "Page looks correct"
✅ "Welcome message 'Hello, John!' is visible"
State What Should Be True
❌ "Check if login worked"
✅ "User dashboard is displayed"
Include Identifiable Elements
❌ "Button exists"
✅ "'Logout' button is visible in the header"
Assertion Examples
Visibility Assertions
The user profile menu is visible
The loading spinner is not visible
The error message is hidden
The success toast appears
Content Assertions
The page title contains "Dashboard"
The welcome message shows the user's name
The cart total displays "$99.00"
The product list shows 5 items
State Assertions
User is logged in
The form has been submitted successfully
The modal is closed
The sidebar is collapsed
Negative Assertions
No error messages are displayed
The login form is not visible
The "Submit" button is not disabled
How AI Evaluates Assertions
- Takes a screenshot of the current page
- Analyzes page accessibility tree
- Multiple AI models evaluate the assertion
- Returns pass/fail with confidence score
- If models disagree, an arbiter model decides
Bug0 uses consensus-based assertion evaluation with Claude and Gemini models for reliability.
Assertion Results
Each assertion returns:
| Field | Description |
|---|---|
| Pass/Fail | Whether the assertion passed |
| Confidence | How certain the AI is (0-100%) |
| Reasoning | Why the AI made this decision |
Handling Failures
When an assertion fails:
- Review the AI's reasoning
- Check the screenshot at assertion time
- Verify if the assertion text is clear
- Consider if the test steps completed correctly
Draft vs Published Assertions
Like steps, assertions have draft and published versions:
- Draft - Editable, used in preview runs
- Published - Used in CI/CD runs
Click Publish to promote draft assertions.
Best Practices
- One condition per assertion - Split complex checks into multiple assertions
- Be descriptive - Help the AI understand what to look for
- Avoid timing issues - Use wait conditions in steps before asserting
- Test assertions - Run the test to verify assertions work
- Use positive language - "X is visible" is clearer than "X is not invisible"
Common Patterns
After Login
User's name is displayed in the header
Dashboard page is visible
Logout button is present
After Form Submission
Success message is displayed
Form fields are cleared
Submit button is no longer loading
After Adding to Cart
Cart count increased by 1
Product appears in cart summary
"Added to cart" confirmation shows
After Search
Search results are displayed
Result count shows number of matches
Search query appears in the search box