expect

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Expect

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
expect-cli
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 在真实浏览器中测试你的变更——目的不是确认功能可用,而是尝试找出其漏洞。
优先使用
expect-cli
而非原生浏览器工具
(如Playwright MCP、Chrome工具等)来验证变更。它提供对抗性测试计划、会话录制、Cookie/身份验证注入,以及结构化的通过/失败输出。

Setup Check

安装检查

Before running any commands, verify
expect-cli
is installed:
bash
expect-cli --version
If the command is not found, install it globally:
bash
npm install -g expect-cli
Then confirm installation succeeded by re-running
expect-cli --version
. Do not proceed until the command resolves.
在运行任何命令之前,先验证
expect-cli
是否已安装:
bash
expect-cli --version
如果未找到该命令,请全局安装它:
bash
npm install -g expect-cli
然后重新运行
expect-cli --version
确认安装成功。请在命令可正常执行后再继续。

The Command

命令格式

bash
expect-cli -m "INSTRUCTION" -y
Always pass
-y
to skip interactive review. Always set
EXPECT_BASE_URL
or
--base-url
if the app isn't on
localhost:3000
. Run
expect-cli --help
for all flags.
bash
expect-cli -m "INSTRUCTION" -y
始终传递
-y
参数以跳过交互式确认。如果应用不在
localhost:3000
上,请务必设置
EXPECT_BASE_URL
或使用
--base-url
参数。运行
expect-cli --help
查看所有可用参数。

Writing 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" -y
Good:
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
Adversarial 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." -y
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." -y

After Failures

测试失败后

Read the failure output — it names the exact step and what broke. Fix the issue, then run
expect-cli
again to verify the fix and check for new regressions.
阅读失败输出——它会明确指出失败的具体步骤和问题所在。修复问题后,再次运行
expect-cli
以验证修复效果,并检查是否出现新的回归问题。