一键导入
sharded-tests
Teach agents to shard and parallelize Playwright, Jest, and pytest suites in CI to reduce wall-clock time while merging reports reliably.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Teach agents to shard and parallelize Playwright, Jest, and pytest suites in CI to reduce wall-clock time while merging reports reliably.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | CI Test Sharding Parallelization |
| description | Teach agents to shard and parallelize Playwright, Jest, and pytest suites in CI to reduce wall-clock time while merging reports reliably. |
| version | 1.0.0 |
| author | thetestingacademy |
| license | MIT |
| tags | ["ci","sharding","parallelization","playwright","jest","pytest","test-performance"] |
| testingTypes | ["e2e","regression","performance"] |
| frameworks | ["playwright","jest","pytest"] |
| languages | ["typescript","python"] |
| domains | ["devops"] |
| agents | ["claude-code","cursor","github-copilot","windsurf","codex","aider","continue","cline","zed","bolt","gemini-cli","amp"] |
You are a test infrastructure engineer who reduces CI wall-clock time by sharding and parallelizing test suites while preserving deterministic results, useful reports, and clear failure ownership.
Create scripts for each framework.
npm install --save-dev @playwright/test jest jest-junit
python -m venv .venv
. .venv/bin/activate
pip install pytest pytest-xdist pytest-json-report
mkdir -p test-results merged-reports
Use consistent environment variables.
export SHARD_INDEX=1
export SHARD_TOTAL=4
export CI_NODE_INDEX=1
export CI_NODE_TOTAL=4
ci/
sharding/
playwright.yml
jest.yml
pytest.yml
scripts/
run-playwright-shard.sh
run-jest-shard.ts
run-pytest-shard.sh
merge-reports.sh
test-results/
merged-reports/
Use the built-in Playwright shard flag.
#!/usr/bin/env bash
set -euo pipefail
: "${SHARD_INDEX:?SHARD_INDEX is required}"
: "${SHARD_TOTAL:?SHARD_TOTAL is required}"
npx playwright test \
--shard="${SHARD_INDEX}/${SHARD_TOTAL}" \
--reporter=blob \
--output="test-results/playwright-${SHARD_INDEX}"
Merge Playwright blob reports after all shards finish.
#!/usr/bin/env bash
set -euo pipefail
mkdir -p merged-reports/playwright
npx playwright merge-reports --reporter html ./blob-report
Use Jest shard support when available.
// scripts/run-jest-shard.ts
import { spawnSync } from 'node:child_process';
const shardIndex = process.env.SHARD_INDEX || '1';
const shardTotal = process.env.SHARD_TOTAL || '1';
const result = spawnSync(
'npx',
[
'jest',
`--shard=${shardIndex}/${shardTotal}`,
'--runInBand',
'--ci',
'--reporters=default',
'--reporters=jest-junit',
],
{ stdio: 'inherit' },
);
process.exit(result.status ?? 1);
Use xdist for process-level parallelism and CI matrix for sharding.
#!/usr/bin/env bash
set -euo pipefail
PYTEST_WORKERS="${PYTEST_WORKERS:-auto}"
REPORT_FILE="test-results/pytest-${SHARD_INDEX:-1}.json"
pytest tests \
-n "$PYTEST_WORKERS" \
--json-report \
--json-report-file="$REPORT_FILE"
Use matrix jobs for Playwright shards.
name: sharded-tests
on:
pull_request:
jobs:
playwright:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npx playwright install --with-deps
- run: bash scripts/run-playwright-shard.sh
env:
SHARD_INDEX: ${{ matrix.shard }}
SHARD_TOTAL: 4
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-blob-${{ matrix.shard }}
path: blob-report
Measure before and after.
| Framework | Sharding Method | Report Merge |
|---|---|---|
| Playwright | --shard=1/4 | Blob report merge |
| Jest | --shard=1/4 | JUnit aggregation |
| pytest | Matrix plus xdist | JSON or JUnit merge |
| Cypress | Dashboard or spec split | Dashboard report |
| Large monorepo | Package filters | Per-package reports |
| Slow E2E | Historical timing split | Custom manifest |
Teach agents to guide manual accessibility audits for keyboard, screen reader, zoom, reflow, focus, and WCAG 2.2 criteria that scanners miss.
Teach agents to use AI browser agents for exploratory and smoke QA with step budgets, evidence-based assertions, guardrails, and Playwright conversion.
Teach agents to build synthetic monitoring as code with Checkly, including Playwright browser checks, API checks, alerting, and CI deploy workflows.
Teach agents to use the Chrome DevTools MCP server for performance testing with traces, Core Web Vitals, throttling, and evidence-based analysis.
Teach agents to run Nuclei DAST and API security scans in CI, write templates, and gate builds on actionable findings.
Teach agents to automate accessibility testing in CI with pa11y and pa11y-ci, including thresholds, sitemap crawling, GitHub Actions gating, and WCAG rule tuning.