feat: add assert commands for test assertions with exit codes#944
Open
mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
Open
feat: add assert commands for test assertions with exit codes#944mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
Conversation
Adds assert visible, hidden, text, url, title, enabled, and checked commands. Each reuses existing daemon actions (isvisible, gettext, etc.) and exits with code 1 on failure. Supports glob matching for URL assertions (* and **). Works in batch mode with --bail.
Contributor
|
@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an
assertcommand family for verifying expected state in automation pipelines. Each command reuses existing daemon actions and exits with code 1 on failure.Commands
assert visible @refassert hidden @refassert text @ref "expected"assert url "**/dashboard"assert title "Page Title"assert enabled @refassert checked @refWhy this matters
The
batchcommand (#865) enables multi-step workflows, but there's no way to verify expected state between steps. Theiscommands (commands.rs:1690) return true/false as JSON but don't fail the process. Assertions with exit codes are the missing piece for CI/CD and agent pipelines.Every testing framework (Playwright, Cypress, Selenium) has assertion primitives. This brings the same capability to agent-browser's CLI.
Changes
cli/src/commands.rs: Newparse_assertfunction (followsparse_ispattern). Sends same daemon actions withassert: truemetadata. Unit tests included.cli/src/main.rs: Assert evaluator intercepts responses before normal output. Prints PASS/FAIL. Glob matcher for URL patterns (*= non-slash,**= any chars). Exits 1 on failure. Works in batch mode with--bail.cli/src/output.rs: Help text for assert commands.No new daemon code - reuses isvisible, isenabled, ischecked, gettext, url, and title actions.
Usage
Testing
cargo checkpasses*and**patternsThis contribution was developed with AI assistance (Claude Code).