Skip to main content
GET
/
api
/
v1
/
analytics
/
test-cases
Test Cases Analytics
curl --request GET \
  --url https://dash.empirical.run/api/v1/analytics/test-cases \
  --header 'Authorization: Bearer <token>'
{
  "data": {
    "test_cases": [
      {
        "test_case_id": "abc-123-def",
        "test_name": "should login successfully",
        "file_path": "tests/auth/login.spec.ts",
        "project_name": "my-project",
        "tags": ["smoke", "auth"],
        "last_run_at": "2025-02-01T10:30:00.000Z",
        "metrics": {
          "total_runs": 20,
          "pass_count": 18,
          "fail_count": 1,
          "flaky_count": 1,
          "pass_rate": 90,
          "fail_rate": 5,
          "flaky_rate": 5
        },
        "history": [
          {
            "timestamp": "2025-02-01T10:30:00.000Z",
            "status": "pass",
            "test_run_id": "12345",
            "environment_id": "1",
            "executed_at": "2025-02-01T10:30:00.000Z",
            "duration_total": 5200,
            "retries": 0
          }
        ]
      }
    ],
    "summary": {
      "total_test_cases": 150,
      "test_cases_with_history": 145
    }
  }
}
Returns test case analytics with aggregated metrics and run history. Supports filtering, searching, and sorting.
{
  "data": {
    "test_cases": [
      {
        "test_case_id": "abc-123-def",
        "test_name": "should login successfully",
        "file_path": "tests/auth/login.spec.ts",
        "project_name": "my-project",
        "tags": ["smoke", "auth"],
        "last_run_at": "2025-02-01T10:30:00.000Z",
        "metrics": {
          "total_runs": 20,
          "pass_count": 18,
          "fail_count": 1,
          "flaky_count": 1,
          "pass_rate": 90,
          "fail_rate": 5,
          "flaky_rate": 5
        },
        "history": [
          {
            "timestamp": "2025-02-01T10:30:00.000Z",
            "status": "pass",
            "test_run_id": "12345",
            "environment_id": "1",
            "executed_at": "2025-02-01T10:30:00.000Z",
            "duration_total": 5200,
            "retries": 0
          }
        ]
      }
    ],
    "summary": {
      "total_test_cases": 150,
      "test_cases_with_history": 145
    }
  }
}

List test cases sorted by fail rate

curl -X GET \
  "https://dash.empirical.run/api/v1/analytics/test-cases?days=7&order_by=fail_rate&limit=50" \
  -H "Authorization: Bearer $EMPIRICALRUN_KEY"

Get history for a single test case

curl -X GET \
  "https://dash.empirical.run/api/v1/analytics/test-cases?test_case_id=abc-123-def&days=30" \
  -H "Authorization: Bearer $EMPIRICALRUN_KEY"
curl -X GET \
  "https://dash.empirical.run/api/v1/analytics/test-cases?search=login&tags=smoke,auth" \
  -H "Authorization: Bearer $EMPIRICALRUN_KEY"

Authorizations

Authorization
string
header
required

API key from the Empirical dashboard.

Query Parameters

days
number

Number of days of history (1-90, default 7). Ignored if start_date and end_date are provided.

start_date
string

Start of custom date range (ISO 8601). Must be used together with end_date.

end_date
string

End of custom date range (ISO 8601). Must be used together with start_date.

environment_id
string

Filter by environment ID.

test_case_id
string

Fetch history for a single test case. When provided, search, tags, order_by, order, and limit are ignored.

Substring match on test name or file path.

tags
string

Comma-separated tags to filter by (includes match).

order_by
string

Sort field. Allowed values: fail_rate, flaky_rate, last_run.

order
string

Sort direction. Allowed values: asc, desc.

limit
number

Maximum number of test cases to return (1-500, default 100).

limit_history
number

Maximum history entries per test case (1-100, default 20).

Response

Test case analytics data.

data
object
required