端到端 (E2E) 测试从用户的角度验证完整的应用程序 — 通过真实系统(UI、后端、数据库)测试完整的工作流程,就像用户会经历的那样。它提供了最高的信心确保整个系统正常工作,但速度较慢且更加脆弱。
E2E 测试做什么
E2E tests verify COMPLETE user flows through the WHOLE system:
→ simulate a real USER: open the app, click/type, navigate, submit, verify results
→ exercise the FULL stack: UI → backend → database → and back (everything integrated)
→ e.g. "user logs in, adds an item to the cart, checks out, sees confirmation"
→ tests the app as users actually experience it.
示例(网络,使用 Playwright/Cypress)
(, ({ page }) => {
page.();
page.(, );
page.(, );
page.();
(page.()).();
});
