Assert a mini program condition
mp_expectEvaluates assertions against a running WeChat Mini Program, reporting pass/fail with observed values and treating failed checks as normal results so one run can surface every broken expectation.
Instructions
Evaluate one assertion against the running app and report pass/fail with the observed value. A failed assertion is a normal result, not an error: check pass and keep going, so one run can surface every broken expectation. Targets cover page data, the route, element text/value/attribute/data, and element counts. Types are compared strictly — "false" does not equal false.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"target": "<target>"
},
"name": "mp_expect"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Attribute name for element_attribute. | |
| path | No | Page data path for page_data, or the route for page_path. | |
| index | No | Which match to read for element_text/attribute/value/data. Defaults to 0. | |
| xpath | No | Treat selector as XPath. | |
| target | Yes | What is observed: page_data, page_path, element_text, element_attribute, element_value, element_count, element_exists, element_data. | |
| matcher | No | Comparison. Defaults per target: equals (most), count (element_count), truthy (element_exists). | |
| expected | No | Value compared against. Omit for exists/truthy. Use a regex source string for matches, a number for count, an array for one_of. | |
| selector | No | Element selector for the element_* targets. | |
| data_path | No | Path inside a custom component data object for element_data. | |
| container_selector | No | Resolve this first and search inside it. |