
davidsiv/sem-playwright本Docker镜像专为CI/CD环境设计,用于简化Playwright自动化测试在持续集成流程中的部署与执行。镜像预安装Playwright及其完整依赖(包括浏览器二进制文件、系统库等),无需额外配置即可直接运行Playwright测试脚本,有效降低CI环境中测试环境搭建的复杂度。
bashdocker run --rm -v $(pwd):/tests playwright-ci-image npx playwright test
-v $(pwd):/tests: 将本地测试文件目录挂载到容器内/tests目录(默认工作目录)npx playwright test: 执行Playwright测试命令(可根据实际测试脚本调整)若测试脚本位于非默认路径或需要指定测试文件:
bashdocker run --rm -v $(pwd)/e2e:/tests playwright-ci-image npx playwright test ./specs/login.spec.ts
指定浏览器运行测试(默认运行所有已安装浏览器):
bashdocker run --rm -v $(pwd):/tests playwright-ci-image npx playwright test --project=chromium docker run --rm -v $(pwd):/tests playwright-ci-image npx playwright test --project=firefox docker run --rm -v $(pwd):/tests playwright-ci-image npx playwright test --project=webkit
| 环境变量 | 说明 | 默认值 |
|---|---|---|
PLAYWRIGHT_BROWSERS_PATH | 浏览器二进制文件存储路径 | /usr/local/share/playwright-browsers |
NODE_ENV | Node.js运行环境 | test |
TEST_REPORT_DIR | 测试报告输出目录 | /tests/reports |
yamlversion: '3.8' services: playwright-test: image: playwright-ci-image volumes: - ./tests:/tests - ./reports:/tests/reports # 挂载报告目录,持久化测试结果 environment: - NODE_ENV=ci - TEST_REPORT_DIR=/tests/reports command: npx playwright test --reporter=html
/tests目录)PLAYWRIGHT_BROWSERS_PATH指定外部浏览器路径--rm参数清理临时容器,减少CI环境存储占用
manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务