Skip to main content

CI/CD

Jihed Othmani avatar
Written by Jihed Othmani
Updated over a month ago

Overview

The Thunders API provides a powerful endpoint for executing automated browser-based tests. This document explains how to use the /api/test-cases/run or /api/test-sets/run endpoint, which allows you to trigger test case execution programmatically, including through GitHub Actions workflows.

API Endpoints

POST <https://api.thunders.ai/api/test-cases/run> 
POST <https://api.thunders.ai/api/test-sets/run>

Authentication

The API requires authentication using a Bearer token:

Authorization: Bearer YOUR_THUNDER_TEST_TOKEN

You must obtain a valid API token from the Thunders platform. This token should be stored securely as a secret in your environment or GitHub repository.

Headers

Header

Value

Description

Authorization

Bearer YOUR_THUNDER_TEST_TOKEN

Authentication token

X-MS-API-ROLE

M2M

Indicates a machine-to-machine API call

Content-Type

application/json

Specifies the request body format

Request Body for Test Case Run

The request body must be a JSON object with the following properties:

{ 
"ProjectId": "c8e34ec4-2464-43c7-8db8-1b3a47a22337",
"TestCaseIds": ["a836fadc-377a-46fe-96b0-21f37c626bf9", "61015c47-612f-47fa-82a6-41d910832c1b", "8eea2fd3-da6d-4434-a310-176be84c5646"], "EnvironmentId": "eca24252-e566-40a8-b2b0-707b7efa85d8",
"PersonaId": "70d0ac52-fe94-4d89-aba9-8ef28dd8c04c",
"BrowserSettings": { "Location": "SanFrancisco", "Resolution": "1440x900", "DeviceType": "Desktop" }
}

Parameters

Parameter

Type

Required

Default

Description

ProjectId

string(UUID)

Yes

-

The unique identifier of the project containing the test cases.

TestCaseIds

array of strings(UUIDs)

Yes

-

Array of test case identifiers to execute.

EnvironmentId

string(UUID)

Yes

-

The unique identifier of the environment to use.

PersonaId

string(UUID)

Yes

-

The unique identifier of the persona to use when executing the tests

BrowserSettings.location

"London"|"Amsterdam"|"SanFrancisco"|"FranceDynamic"

No

"London"

Geolocation cluster for the browser session.

BrowserSettings.browserType

"Chromium"|"Chrome"|"Firefox"|"Safari"

No

"Chromium"

Type of browser to use for the test execution

BrowserSettings.deviceType

"Desktop"|"Mobile"|"Tablet"

No

"Desktop"

Type of device to emulate during test execution

BrowserSettings.resolution

string

No

"1280x720"

Browser viewport resolution in pixels, in the format "widthxheight"

BrowserSettings.javascript

boolean

No

true

Enable or disable JavaScript execution in the browser. Note that some test steps rely on this option being set to true.

BrowserSettings.ignoreHttpsErrors

boolean

No

false

Whether to ignore HTTPS errors during navigation

BrowserSettings.darkTheme

boolean

No

false

Enable or disable dark theme for the browser

BrowserSettings.avoidDetection

boolean

No

false

Enable measures to avoid bot detection during test execution

BrowserSettings.deviceScaleFactor

number

No

-

Scale factor for the device screen

BrowserSettings.forcedColors

string

No

-

Force specific color scheme for accessibility testing

BrowserSettings.locale

string

No

-

Browser locale setting (e.g., "en-US", "fr-FR")

BrowserSettings.username

string

No

-

Username for authentication

BrowserSettings.password

string

No

-

Password for authentication

BrowserSettings.proxy

string

No

-

Proxy server configuration

BrowserSettings.headers

dictionary

No

-

Custom HTTP headers to include in requests

Request Body for Test Set Run

The request body must be a JSON object with the following properties:

{ "ProjectId": "c8e34ec4-2464-43c7-8db8-1b3a47a22337", 
"TestSetIds": ["a836fadc-377a-46fe-96b0-21f37c626bf9", "61015c47-612f-47fa-82a6-41d910832c1b", "8eea2fd3-da6d-4434-a310-176be84c5646"], "EnvironmentId": "eca24252-e566-40a8-b2b0-707b7efa85d8",
"PersonaId": "70d0ac52-fe94-4d89-aba9-8ef28dd8c04c",
"BrowserSettings": { "Location": "SanFrancisco", "resolution": "1440x900", }
}

Parameters

Parameter

Type

Required

Default

Description

ProjectId

string(UUID)

Yes

-

The unique identifier of the project containing the test cases.

TestSetIds

array of strings(UUIDs)

Yes

-

Array of test set identifiers to execute.

EnvironmentId

string(UUID)

Yes

-

The unique identifier of the environment to use.

PersonaId

string(UUID)

Yes

-

The unique identifier of the persona to use when executing the tests

BrowserSettings.location

"London"|"Amsterdam"|"SanFrancisco"|"FranceDynamic"

No

"London"

Geolocation cluster for the browser session.

BrowserSettings.browserType

"Chromium" |"Chrome"|"Firefox"|"Safari"

No

"Chromium"

Type of browser to use for the test execution

BrowserSettings.deviceType

"Desktop"|"Mobile"|"Tablet"

No

"Desktop"

Type of device to emulate during test execution

BrowserSettings.resolution

string

No

"1280x720"

Browser viewport resolution in pixels, in the format "widthxheight"

BrowserSettings.javascript

boolean

No

true

Enable or disable JavaScript execution in the browser. Note that some test steps rely on this option being set to true.

BrowserSettings.ignoreHttpsErrors

boolean

No

false

Whether to ignore HTTPS errors during navigation

BrowserSettings.darkTheme

boolean

No

false

Enable or disable dark theme for the browser

BrowserSettings.avoidDetection

boolean

No

false

Enable measures to avoid bot detection during test execution

BrowserSettings.deviceScaleFactor

number

No

-

Scale factor for the device screen

BrowserSettings.forcedColors

string

No

-

Force specific color scheme for accessibility testing

BrowserSettings.locale

string

No

-

Browser locale setting (e.g., "en-US", "fr-FR")

BrowserSettings.username

string

No

-

Username for authentication

BrowserSettings.password

string

No

-

Password for authentication

BrowserSettings.proxy

string

No

-

Proxy server configuration

BrowserSettings.headers

dictionary

No

-

Custom HTTP headers to include in requests

Response

The API returns a response with details about the test execution. The exact format may vary depending on the test results, but typically includes:

  • Test execution status

  • Test results summary

  • Detailed results for each test case

  • Any errors or failures encountered

Error Handling

The API uses standard HTTP status codes to indicate success or failure:

  • 200 OK: The request was successful, and the tests were executed

  • 400 Bad Request: The request was malformed or missing required parameters

  • 401 Unauthorized: Authentication failed or token is invalid

  • 403 Forbidden: The authenticated user does not have permission to execute the specified tests

  • 404 Not Found: One or more of the specified resources (project, test cases, environment, or persona) were not found

  • 500 Internal Server Error: An unexpected error occurred on the server

Using with GitHub Actions

You can easily integrate the Thunder Code API with your GitHub Actions workflows to automate test execution as part of your CI/CD pipeline.

Example GitHub Action Workflow

name: Run Thunders Test Cases

on:
workflow_dispatch: # This allows manual triggering from the GitHub UI
# You can add other triggers here as needed, such as:
# push:
# branches: [ main ]
# schedule:
# - cron: '0 0 * * *' # Run daily at midnight

jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run Thunders API Test Cases
id: run-tests
uses: fjogeleit/http-request-action@v1
with:
url: '<https://api.thunders.ai/api/test-cases/run>'
method: 'POST'
customHeaders: >
{
"Authorization": "Bearer ${{ secrets.THUNDER_TEST_TOKEN }}",
"X-MS-API-ROLE": "M2M",
"Content-Type": "application/json"
}
data: >
{
"ProjectId": "c8e34ec4-2464-43c7-8db8-1b3a47a22337",
"TestCaseIds": ["a836fadc-377a-46fe-96b0-21f37c626bf9", "61015c47-612f-47fa-82a6-41d910832c1b", "8eea2fd3-da6d-4434-a310-176be84c5646"],
"EnvironmentId": "eca24252-e566-40a8-b2b0-707b7efa85d8",
"PersonaId": "70d0ac52-fe94-4d89-aba9-8ef28dd8c04c"
}

- name: Output API Response
if: ${{ success() }}
run: echo "API Response - ${{ steps.run-tests.outputs.response }}"

Setting Up GitHub Secrets

To use the Thunders API in your GitHub Actions workflow, you need to set up a secret for your API token:

  1. Go to your GitHub repository

  2. Navigate to Settings > Secrets and variables > Actions

  3. Click "New repository secret"

  4. Name: THUNDER_TEST_TOKEN

  5. Value: Your Thunders API token

  6. Click "Add secret"

Customizing the Workflow

You can customize the workflow by:

  1. Changing the trigger events (e.g., on push, on schedule)

  2. Modifying the test parameters (ProjectId, TestCaseIds, TestSetIds, EnvironmentId, PersonaId)

  3. Adding additional steps to process the test results

Did this answer your question?