构建Headless 的 E2E 测试
为什么要构建 Headless 的 E2E 测试
A headless browser is a great tool for automated testing and server environments where you don't need a visible UI shell. For example, you may want to run some tests against a real web page, create a PDF of it, or just inspect how the browser renders an URL.
结合上面的原因,我们还可以
- Headless结合 E2E 测试,可以让E2E 测试在非 GUI 的操作系统中运行
- 可以集成至 CI 环境中。让版本得到快速验证
Chrome Headless 的选取
- Mac/Linux 的Chrome从59版本后,已经支持 Healess 模式的运行。Windows 的从60版本开始支持
- 所以选择一个你想要的 Chrome 版本,便可以进行 Headless 的测试
chrome \
--headless \ # Runs Chrome in headless mode.
--disable-gpu \ # Temporarily needed if running on Windows.
https://www.chromestatus.com # URL to open. Defaults to about:blank.
……