Skip to content

Implement custom assertion templating for mcp server#1

Open
etnlbck wants to merge 1 commit intomainfrom
cursor/implement-custom-assertion-templating-for-mcp-server-d5c1
Open

Implement custom assertion templating for mcp server#1
etnlbck wants to merge 1 commit intomainfrom
cursor/implement-custom-assertion-templating-for-mcp-server-d5c1

Conversation

@etnlbck
Copy link
Owner

@etnlbck etnlbck commented Sep 26, 2025

Add assert_template MCP tool to enable templated custom assertions.


Open in Cursor Open in Web

Co-authored-by: me <me@natelubeck.com>
@cursor
Copy link

cursor bot commented Sep 26, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@etnlbck etnlbck marked this pull request as ready for review October 3, 2025 19:36
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

return re ? re.test(text) : false;
}
if (typeof a.expected === "string") {
return a.comparator === "contains" || a.contains ? text.includes(a.expected) : text === a.expected;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

return re ? re.test(val) : false;
}
if (a.expected !== undefined && a.comparator !== "contains" && a.comparator !== "matches") {
return String(val) === String(a.expected);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants