expect
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseExpect
Expect
Adversarial browser testing for code changes. Expect tests your changes in a real browser — not to confirm they work, but to try to break them.
Use instead of raw browser tools (Playwright MCP, chrome tools, etc.) for verifying changes. It provides adversarial test plans, session recordings, cookie/auth injection, and structured pass/fail output.
expect-cli针对代码变更的对抗性浏览器测试。Expect 在真实浏览器中测试你的变更——目的不是确认功能可用,而是尝试找出其漏洞。
优先使用而非原生浏览器工具(如Playwright MCP、Chrome工具等)来验证变更。它提供对抗性测试计划、会话录制、Cookie/身份验证注入,以及结构化的通过/失败输出。
expect-cliSetup Check
安装检查
Before running any commands, verify is installed:
expect-clibash
expect-cli --versionIf the command is not found, install it globally:
bash
npm install -g expect-cliThen confirm installation succeeded by re-running . Do not proceed until the command resolves.
expect-cli --version在运行任何命令之前,先验证是否已安装:
expect-clibash
expect-cli --version如果未找到该命令,请全局安装它:
bash
npm install -g expect-cli然后重新运行确认安装成功。请在命令可正常执行后再继续。
expect-cli --versionThe Command
命令格式
bash
expect-cli -m "INSTRUCTION" -yAlways pass to skip interactive review. Always set or if the app isn't on . Run for all flags.
-yEXPECT_BASE_URL--base-urllocalhost:3000expect-cli --helpbash
expect-cli -m "INSTRUCTION" -y始终传递参数以跳过交互式确认。如果应用不在上,请务必设置或使用参数。运行查看所有可用参数。
-ylocalhost:3000EXPECT_BASE_URL--base-urlexpect-cli --helpWriting Instructions
编写测试指令
Think like a user trying to break the feature, not a QA checklist confirming it renders.
Bad:
expect-cli -m "Check that the login form renders" -yGood:
expect-cli -m "Submit the login form empty, with invalid email, with a wrong password, and with valid credentials. Verify error messages for bad inputs and redirect on success. Check console errors after each." -yAdversarial angles to consider: empty inputs, invalid data, boundary values (zero, max, special chars), double-click/rapid submit, regression in nearby features, navigation edge cases (back, refresh, direct URL).
要站在试图破坏功能的用户角度思考,而非编写确认页面渲染的QA检查清单。
错误示例:
expect-cli -m "Check that the login form renders" -y正确示例:
expect-cli -m "Submit the login form empty, with invalid email, with a wrong password, and with valid credentials. Verify error messages for bad inputs and redirect on success. Check console errors after each." -y可考虑的对抗性测试角度包括:空输入、无效数据、边界值(如零、最大值、特殊字符)、双击/快速提交、邻近功能的回归问题、导航边缘情况(后退、刷新、直接访问URL)。
When to Run
运行时机
After any browser-facing change: components, pages, forms, routes, API calls, data fetching, styles, layouts, bug fixes, refactors. When in doubt, run it.
在任何面向浏览器的变更完成后运行:包括组件、页面、表单、路由、API调用、数据获取、样式、布局、Bug修复、代码重构。如有疑问,就运行它。
Example
示例
bash
EXPECT_BASE_URL=http://localhost:5173 expect-cli -m "Test the checkout flow end-to-end with valid data, then try to break it: empty cart submission, invalid card numbers, double-click place order, back button mid-payment. Verify error states and console errors." -ybash
EXPECT_BASE_URL=http://localhost:5173 expect-cli -m "Test the checkout flow end-to-end with valid data, then try to break it: empty cart submission, invalid card numbers, double-click place order, back button mid-payment. Verify error states and console errors." -yAfter Failures
测试失败后
Read the failure output — it names the exact step and what broke. Fix the issue, then run again to verify the fix and check for new regressions.
expect-cli阅读失败输出——它会明确指出失败的具体步骤和问题所在。修复问题后,再次运行以验证修复效果,并检查是否出现新的回归问题。
expect-cli