Tests

Tests are the core component of Magic Inspector. Through these endpoints, you can list all tests in a project and trigger test executions.

The test model

The test model contains all the information about your tests, including their name, ID, and associated run links.

Properties

  • Name
    id
    Type
    string
    Description

    Unique identifier for the test.

  • Name
    name
    Type
    string
    Description

    The name of the test.

  • Name
    links
    Type
    object
    Description
  • Name
    run
    Type
    string
    Description

    URL to trigger a test run.


GET/v1/projects/{projectId}/tests

List all tests

This endpoint allows you to retrieve a list of all tests in a project.

Required parameters

  • Name
    projectId
    Type
    string
    Description

    The ID of the project containing the tests.

Required headers

  • Name
    X-Api-Key
    Type
    string
    Description

    Your project API key for authentication.

Request

GET
/v1/projects/proj_123/tests
curl https://api.magicinspector.com/v1/projects/proj_123/tests \
  -H "X-Api-Key: {your-api-key}"

Response

{
  "data": [
    {
      "id": "test_123",
      "name": "Homepage Test",
      "links": {
        "run": "https://api.magicinspector.com/v1/projects/proj_123/tests/test_123/trigger-run"
      }
    }
  ],
  "meta": {
    "total": 1
  }
}

POST/v1/projects/{projectId}/tests/{testId}/trigger-run

Trigger a test run

This endpoint allows you to trigger the execution of a specific test.

Required parameters

  • Name
    projectId
    Type
    string
    Description

    The ID of the project containing the test.

  • Name
    testId
    Type
    string
    Description

    The ID of the test to run.

Optional attributes

  • Name
    overrideDomain
    Type
    string
    Description

    The test start URL to override the default one.

Request

POST
/v1/projects/proj_123/tests/test_123/trigger-run
curl -X POST https://api.magicinspector.com/v1/projects/proj_123/tests/test_123/trigger-run \
  -H "X-Api-Key: {your-api-key}" \
  -d '{"overrideDomain": "https://staging.example.com"}'

Response

{
  "data": {
    "id": "run_123",
    "status": "queued",
    "startedAt": null
  },
  "links": {
    "status": "https://api.magicinspector.com/v1/projects/proj_123/runs/run_123/status"
  }
}

Was this page helpful?