> ## Documentation Index
> Fetch the complete documentation index at: https://docs.peak.inc/llms.txt
> Use this file to discover all available pages before exploring further.

# Test analytics

> Upload JUnit results to find failing, flaky, and slow tests.

> [!NOTE]
>
> Ask Peak to turn on test analytics for your workspace.

## Before you start

Make your test runner write JUnit XML.

| Runner | Option |
| - | - |
| Node.js | --test-reporter=junit --test-reporter-destination=junit.xml |
| Jest | jest-junit reporter |
| Vitest | --reporter=junit --outputFile=junit.xml |
| pytest | --junitxml=junit.xml |
| Go | gotestsum --junitfile junit.xml |
| Playwright | --reporter=junit with PLAYWRIGHT\_JUNIT\_OUTPUT\_NAME=junit.xml |
| Maven, Gradle | TEST-\*.xml reports |

## Create a token

1. Open Settings → API access → Create token.
2. Select Upload test results.
3. Copy the token.
4. Store it as a repository secret named PEAK\_TOKEN.

## Upload results

Add this step after your tests.

```yaml theme={null}
- name: Upload test results to Peak
  if: ${{ !cancelled() }}
  continue-on-error: true
  env:
    PEAK_TOKEN: ${{ secrets.PEAK_TOKEN }}
    JOB_ID: ${{ job.check_run_id }}
  run: |
    gzip -c junit.xml | curl --fail-with-body -sS https://app.peak.inc/api/v1/test-results \
      -H "Authorization: Bearer $PEAK_TOKEN" -H 'Content-Type: application/xml' -H 'Content-Encoding: gzip' \
      --url-query "repository=$GITHUB_REPOSITORY" --url-query "repository_id=$GITHUB_REPOSITORY_ID" \
      --url-query "run_id=$GITHUB_RUN_ID" --url-query "run_attempt=$GITHUB_RUN_ATTEMPT" \
      --url-query "job=$GITHUB_JOB" --url-query "job_id=$JOB_ID" --url-query "sha=$GITHUB_SHA" \
      --url-query "branch=${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}" --url-query "workflow=$GITHUB_WORKFLOW" \
      --url-query "root=$GITHUB_WORKSPACE" --data-binary @-
```

Replace junit.xml with your report's path.
For several reports in one job, upload each file and add a name for each.

```text theme={null}
--url-query "report=unit"
```

Keep job\_id in the step.
It keeps matrix jobs apart.

## Read the results

Open [Insights](https://app.peak.inc/runs/insights) → Tests.
Check Tests, Failed, Flaky, and Test time p50.
Check Most failing, Flaky, and Slowest.
Open a test for its history.

Open a failed run to see its failed tests.

Expect a test to count as flaky when it passed and failed on the same commit, or passed on a retry in the same job.

## Check limits

| Limit | Value |
| - | - |
| Upload size | 20 MB compressed, 32 MB of XML |
| Tests per upload | 20,000 |
| Uploads per workspace | 1,000 per hour |
| Retention | 30 days |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.