Implement custom assertion templating for mcp server#1
Conversation
Co-authored-by: me <me@natelubeck.com>
|
Cursor Agent can help with this pull request. Just |
There was a problem hiding this comment.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on November 23
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| private retryCount = 0; | ||
| private maxRetries = 3; | ||
| // Declaration for late-bound evaluator implementation | ||
| private evaluateAssertionTemplate!: (page: Page, assertions: AssertionCondition[]) => Promise<AssertionSummary>; |
There was a problem hiding this comment.
Bug: Method Not Assigned Before Use
The evaluateAssertionTemplate method is declared with a definite assignment assertion (!) but is only assigned to the class prototype after the class definition. This can lead to a runtime error, like "not a function," if the method is called before its prototype assignment executes, particularly during module loading or early instantiation.
| return re ? re.test(text) : false; | ||
| } | ||
| if (typeof a.expected === "string") { | ||
| return a.comparator === "contains" || a.contains ? text.includes(a.expected) : text === a.expected; |
There was a problem hiding this comment.
Bug: Text Assertion Substring Logic Flaw
The text assertion's substring matching logic is inconsistent. The condition a.comparator === "contains" || a.contains can incorrectly trigger includes() when a.contains is present. More critically, when a.contains is provided, the assertion uses a.expected for the comparison instead of a.contains.
| return re ? re.test(val) : false; | ||
| } | ||
| if (a.expected !== undefined && a.comparator !== "contains" && a.comparator !== "matches") { | ||
| return String(val) === String(a.expected); |
There was a problem hiding this comment.
Bug: Attribute Assertion Logic Mismatch
In the attribute assertion, the logic for a.expected and a.contains is inconsistent. If a.comparator is "contains" or "matches", the a.expected value is ignored, and the assertion incorrectly falls back to checking the separate a.contains field. This can lead to unexpected assertion results.
Add
assert_templateMCP tool to enable templated custom assertions.