What you’ll learn
- How to upload Playwright results from Amazon CodeBuild to TestDino
- How to configure sharded test runs with merged reporting
- How to set up the TESTDINO_TOKEN as a CodeBuild environment variable
Prerequisites
Before setting up, ensure you have:- A TestDino account with a project created
- A TestDino API key (Generate API Keys)
- An AWS account with CodeBuild access
- A Playwright test project (or clone the TestDino Example Repository to get started)
- Playwright configured with JSON and HTML reporters in
playwright.config.js:
playwright.config.js
Set Up Your API Key
Store your TestDino API key as a CodeBuild environment variable so it is available to your build without exposing it in buildspec files.- Open your AWS CodeBuild project
- Choose Edit
- Open the Environment section
- Add an environment variable named
TESTDINO_TOKEN - Paste your TestDino API key as the value
- Save the project
Basic Buildspec Config
For a simple setup without sharding, add the upload step after your Playwright tests.buildspec.yml
Upload Options
| Flag | Description | Default |
|---|---|---|
--environment <value> | Target environment tag (staging, production, qa) | unknown |
--tag <values> | Comma-separated run tags for categorization (max 5) | None |
--upload-images | Upload image attachments | false |
--upload-videos | Upload video attachments | false |
--upload-html | Upload HTML reports | false |
--upload-traces | Upload trace files | false |
--upload-files | Upload file attachments (.md, .pdf, .txt, .log) | false |
--upload-full-json | Upload all attachments | false |
--json | Output results as JSON to stdout (for CI/CD) | false |
-v, --verbose | Enable verbose logging | false |
Sharded Test Runs
For larger test suites, CodeBuild runs Playwright across multiple shard passes within a single build. Each shard produces a blob report that gets merged before uploading to TestDino.How it works
- CodeBuild runs 4 Playwright shard passes sequentially in a single build
- Each shard’s blob report is copied to a dedicated directory
- All blob reports are flattened and merged into a single
report.json - The merged report is uploaded to TestDino
- The build fails only if both tests and the merge/upload fail
Full sharded config
buildspec.yml
Key details
| Config Block | What It Does |
|---|---|
runtime-versions: nodejs: 20 | Uses Node.js 20 managed runtime |
for SHARD in 1 2 3 4 | Runs 4 shard passes sequentially within a single build |
--shard=$SHARD/4 | Passes the shard value directly to Playwright |
cp -R blob-report/. "all-blob-reports/shard-$SHARD/" | Copies each shard’s blob report to a dedicated directory |
find ... -exec cp | Flattens all blob files into a single directory for merging |
merge-reports --reporter=json | Merges blob reports into a single report.json |
TEST_EXIT_CODE / MERGE_AND_UPLOAD_EXIT_CODE | Tracks failures independently so upload runs even if tests fail |
artifacts | Saves Playwright reports and test results to S3 |
Rerun Failed Tests
Cache test metadata to enable selective reruns:buildspec.yml
buildspec.yml
Troubleshooting
Upload step skipped after test failure
Upload step skipped after test failure
Move the upload command to the
post_build phase, which runs regardless of the build phase exit code. For the sharded buildspec, the script tracks exit codes independently so upload always runs.report.json not found
report.json not found
Verify your
playwright.config.js includes both HTML and JSON reporters with HTML listed first. For sharded runs, ensure each shard’s blob-report directory exists before copying. Check that the find command locates files in all-blob-reports-flat/.TESTDINO_TOKEN not available in build
TESTDINO_TOKEN not available in build
Confirm the environment variable is set in your CodeBuild project under Environment → Environment variables. If using Parameter Store or Secrets Manager, verify the IAM role has read access to the secret.
Blob reports not found during merge
Blob reports not found during merge
Ensure each shard pass produces a
blob-report directory. Check that your Playwright config includes ['blob'] in the reporter list or that the default blob output is not overridden. Verify the cp -R command copies files before rm -rf blob-report clears them.Next Steps
CI Optimization
Reduce CI time with smart reruns
Branch Mapping
Map branches to environments for organized test runs
Integrations
Connect Slack, Jira, Linear, Asana, and more
TestDino MCP
Access test results and fix issues with AI agents