playwright-ci

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Playwright CI/CD

Playwright CI/CD

Ship reliable tests in every pipeline — CI-specific patterns for speed, stability, and actionable reports.
9 guides covering CI/CD setup, parallel execution, containerized runs, reporting, and infrastructure patterns for all major CI providers.
在每个流水线中交付可靠的测试 —— 针对CI优化的模式,兼顾速度、稳定性和可执行的报告。
9份指南,涵盖所有主流CI提供商的CI/CD设置、并行执行、容器化运行、报告以及基础设施模式。

Golden Rules

黄金准则

  1. retries: 2
    in CI only
    — surface flakiness in pipelines, not locally
  2. traces: 'on-first-retry'
    — capture rich debugging artifacts without slowing every run
  3. Shard across runners
    --shard=N/M
    splits tests evenly; scale horizontally, not vertically
  4. Cache browser binaries
    ~/.cache/ms-playwright
    keyed on Playwright version
  5. Upload artifacts on failure — traces, screenshots, and HTML reports as CI artifacts
  6. Use the official Docker image
    mcr.microsoft.com/playwright:v*
    has all OS deps pre-installed
  7. Global setup for auth — run login once in
    globalSetup
    , reuse
    storageState
    across workers
  8. Fail fast, debug later — keep CI runs short; use trace viewer and HTML reports to investigate
  1. 仅在CI中设置
    retries: 2
    —— 在流水线中暴露不稳定测试,而非本地环境
  2. traces: 'on-first-retry'
    —— 捕获丰富的调试工件,且不会拖慢每次运行
  3. 在多个运行器间分片 ——
    --shard=N/M
    均匀拆分测试;横向扩展,而非纵向扩展
  4. 缓存浏览器二进制文件 —— 基于Playwright版本缓存
    ~/.cache/ms-playwright
    目录
  5. 失败时上传工件 —— 将追踪文件、截图和HTML报告作为CI工件上传
  6. 使用官方Docker镜像 ——
    mcr.microsoft.com/playwright:v*
    预安装了所有系统依赖
  7. 全局设置用于身份验证 —— 在
    globalSetup
    中执行一次登录,在多个工作进程间复用
    storageState
  8. 快速失败,事后调试 —— 缩短CI运行时间;使用追踪查看器和HTML报告进行问题排查

Guide Index

指南索引

CI Providers

CI提供商

ProviderGuide
GitHub Actionsci-github-actions.md
GitLab CIci-gitlab.md
CircleCI / Azure DevOps / Jenkinsci-other.md
提供商指南
GitHub Actionsci-github-actions.md
GitLab CIci-gitlab.md
CircleCI / Azure DevOps / Jenkinsci-other.md

Execution & Scaling

执行与扩展

TopicGuide
Parallel execution & shardingparallel-and-sharding.md
Docker & containersdocker-and-containers.md
Multi-project configprojects-and-dependencies.md
主题指南
并行执行与分片parallel-and-sharding.md
Docker与容器docker-and-containers.md
多项目配置projects-and-dependencies.md

Reporting & Setup

报告与设置

TopicGuide
Reports & artifactsreporting-and-artifacts.md
Code coveragetest-coverage.md
Global setup/teardownglobal-setup-teardown.md
主题指南
报告与工件reporting-and-artifacts.md
代码覆盖率test-coverage.md
全局启动/清理global-setup-teardown.md