---
title: "Compare test metrics"
method: GET
path: "/api/v1/user/projects/{projectId}/compare-test"
tags: ["Test History"]
---

# Compare test metrics

`GET /api/v1/user/projects/{projectId}/compare-test`

## Request

- Base URL: `https://app.gaffer.sh`
- URL: `https://app.gaffer.sh/api/v1/user/projects/{projectId}/compare-test`
- Auth: one of:
  - API key in header `X-API-Key`
  - API key in header `X-API-Key`
  - HTTP bearer

Compare test metrics between two commits or two test runs.
Provide either (`beforeCommit` + `afterCommit`) or (`beforeRunId` + `afterRunId`).

## Path parameters

- `projectId` string, required

## Query parameters

- `testName` string, required
- `beforeCommit` string
- `afterCommit` string
- `beforeRunId` string
- `afterRunId` string

## Response `200`

Test comparison result

- TestComparisonResponse: Before/after comparison of a specific test across commits or test runs.
  - `testName` string, required
  - `before` TestMetric, required
    - `testRunId` string, required
    - `commit` string, nullable
    - `branch` string, nullable
    - `status` 'passed' | 'failed' | 'skipped', required
    - `durationMs` number, nullable
    - `createdAt` string, date-time, required
  - `after` TestMetric, required
    - `testRunId` string, required
    - `commit` string, nullable
    - `branch` string, nullable
    - `status` 'passed' | 'failed' | 'skipped', required
    - `durationMs` number, nullable
    - `createdAt` string, date-time, required
  - `change` object, required
    - `durationMs` number, nullable: Duration change in milliseconds (positive = slower)
    - `percentChange` number, nullable: Percentage change in duration
    - `statusChanged` boolean, required

## Other responses

- `400`: Invalid request parameters
- `401`: Missing or invalid API key
- `404`: Resource not found

---

[API](https://skmtc.dev/gaffer/apis/gaffer-api.md) · [All operations](https://skmtc.dev/gaffer/apis/gaffer-api/llms.txt) · [OpenAPI document](https://skmtc.dev/gaffer/apis/gaffer-api/revisions/d742ab303118?raw)
