Skip to main content
What you’ll learn
  • How to upload Playwright results from GitLab CI/CD to TestDino
  • How to configure sharded test runs with merged reporting
Set up a GitLab CI/CD pipeline to upload Playwright test results to TestDino and view aggregated analytics, failure analysis, and flaky test detection on your dashboard. This guide covers a basic pipeline, sharded pipeline for parallel test execution across multiple shards, and merged reporting.

Prerequisites

Before setting up, ensure you have:
playwright.config.js
// ...existing config

reporter: [
  ['html', { outputDir: './playwright-report' }],  // Optional
  ['json', { outputFile: './playwright-report/report.json' }],  // ✅ Required
]

Set Up Your API Key

  1. Go to your GitLab project
  2. Open Settings → CI/CD
  3. Expand the Variables section
  4. Click Add variable
  5. Set the key to TESTDINO_TOKEN
  6. Paste your TestDino API key as the value
  7. Check Mask variable to hide it from job logs
  8. Save the variable
WarningNever commit your API key directly in pipeline files. Always use CI/CD variables. Masked variables are hidden from job output.

Basic Pipeline Config

For a simple setup without sharding, add the upload step after your Playwright tests.
.gitlab-ci.yml
image: mcr.microsoft.com/playwright:v1.59.1-noble

variables:
  CI: "true"

stages:
  - test

playwright:
  stage: test
  script:
    - npm ci
    - npx playwright test
    - npx tdpw upload ./playwright-report --token="$TESTDINO_TOKEN"
  artifacts:
    when: always
    paths:
      - playwright-report/
      - test-results/
    expire_in: 14 days
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    - if: $CI_PIPELINE_SOURCE == "web"
TipThe artifacts: when: always ensures test results are saved even if tests fail.

Upload Options

FlagDescriptionDefault
--environment <value>Target environment tag (staging, production, qa)unknown
--tag <values>Comma-separated run tags for categorization (max 5)None
--upload-imagesUpload image attachmentsfalse
--upload-videosUpload video attachmentsfalse
--upload-htmlUpload HTML reportsfalse
--upload-tracesUpload trace filesfalse
--upload-filesUpload file attachments (.md, .pdf, .txt, .log)false
--upload-full-jsonUpload all attachmentsfalse
--jsonOutput results as JSON to stdout (for CI/CD)false
-v, --verboseEnable verbose loggingfalse

Sharded Test Runs

For larger test suites, GitLab CI/CD parallel keyword splits tests across multiple jobs. Each shard produces a blob report that gets merged before uploading to TestDino.

How it works

  1. GitLab CI/CD runs Playwright across 4 parallel shards
  2. Each shard saves its blob report as a job artifact
  3. A separate merge-report job collects all blob reports, merges them into a single report.json, and uploads to TestDino
  4. The merge job runs even if some shards fail (when: always)

Full sharded config

.gitlab-ci.yml
image: mcr.microsoft.com/playwright:v1.59.1-noble

stages:
  - test
  - report

variables:
  CI: "true"

playwright:
  stage: test
  parallel: 4
  script:
    - npm ci
    - npx playwright test --shard=$CI_NODE_INDEX/$CI_NODE_TOTAL
  artifacts:
    when: always
    paths:
      - blob-report/
      - test-results/
    expire_in: 14 days
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    - if: $CI_PIPELINE_SOURCE == "web"

merge-report:
  stage: report
  when: always
  needs:
    - job: playwright
      artifacts: true
  script:
    - npm ci
    - mkdir -p merged-blob-reports playwright-report
    - find . -type f -path "*/blob-report/*.zip" -exec cp {} merged-blob-reports/ \;
    - npx playwright merge-reports --reporter=json ./merged-blob-reports > playwright-report/report.json
    - npx tdpw upload ./playwright-report --token="$TESTDINO_TOKEN"
  artifacts:
    when: always
    paths:
      - playwright-report/
    expire_in: 14 days

Key details

Config BlockWhat It Does
parallel: 4Runs 4 shard jobs in parallel
--shard=$CI_NODE_INDEX/$CI_NODE_TOTALGitLab provides 1-based index and total count automatically
artifacts: when: alwaysSaves blob reports even if shards fail
needs: - job: playwrightDownloads artifacts from all parallel shard jobs
when: always on merge jobEnsures merge and upload run regardless of shard outcomes

Pipeline execution

After the pipeline runs, GitLab shows all shard jobs and the merge stage in the pipeline view. GitLab CI/CD pipeline execution view showing 4 Playwright shard jobs and merge-report stage

Results in TestDino

Once uploaded, the test run appears in your TestDino dashboard with full failure details, flaky detection, and trend data. TestDino test run screen showing uploaded results from GitLab CI/CD pipeline

Rerun Failed Tests

Cache test metadata to enable selective reruns:
.gitlab-ci.yml
playwright:
  stage: test
  script:
    - npm ci
    - npx playwright test
    - npx tdpw cache --token="$TESTDINO_TOKEN"
    - npx tdpw upload ./playwright-report --token="$TESTDINO_TOKEN" --upload-full-json
  artifacts:
    when: always
    paths:
      - playwright-report/
Rerun only failed tests on the next run:
.gitlab-ci.yml
rerun-failed:
  stage: test
  script:
    - npm ci
    - FAILED=$(npx tdpw last-failed --token="$TESTDINO_TOKEN")
    - |
      if [ -n "$FAILED" ]; then
        npx playwright test $FAILED
      else
        echo "No failed tests found."
      fi
  when: manual
For advanced rerun strategies, caching patterns, and CI optimization techniques, see CI Optimization.

Troubleshooting

Ensure artifacts: when: always is set on the test job so blob reports are saved on failure. The merge-report job must use when: always to run regardless of shard outcomes.
Verify your playwright.config.js includes both HTML and JSON reporters with HTML listed first. For sharded runs, ensure blob reports are listed in the test job artifacts: paths.
Confirm the variable is set in Settings → CI/CD → Variables. If the variable is marked Protected, it is only available on protected branches.

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

GitLab OAuth Integration

MR comments and merge request sync