### Example GitLab CI/CD Pipeline Configuration Source: https://docs.bugbug.io/llms-full.txt This snippet shows how to add a job to your `.gitlab-ci.yml` file to install the BugBug CLI, configure your API token, and run a test suite. ```yaml bugbug_tests: image: node:22 stage: test script: - npm install -g @testrevolution/bugbug-cli - bugbug config set-token "$BUGBUG_API_TOKEN" - bugbug remote run suite only: - main ``` -------------------------------- ### Example CI/CD Build Script Snippet Source: https://docs.bugbug.io/integrations/api This is an example of what you can add to your build script to integrate BugBug tests. ```bash echo "Here's an example of what you can add to your build script: " ``` -------------------------------- ### Example Success Response (JSON) Source: https://docs.bugbug.io/public-api-reference/config An example of a successful JSON response when retrieving configuration data. This structure is typical for successful API calls. ```JSON { "ips": [ "1.2.3.4", "5.6.7.8" ] } ``` -------------------------------- ### List Test Suites via CLI Source: https://docs.bugbug.io/integrations/api Use the 'bugbug help' command to see available commands. This example shows how to list test suites within the connected project. ```bash bugbug help ``` ```bash bugbug suites list ``` -------------------------------- ### Install BugBug CLI Source: https://docs.bugbug.io/integrations/api Install the BugBug CLI globally using npm. Ensure you have Node.js version 20 or newer installed. ```bash npm install -g @testrevolution/bugbug-cli ``` -------------------------------- ### Fetch IP Configuration using Python Source: https://docs.bugbug.io/public-api-reference/config This Python example shows how to fetch IP configuration using the 'requests' library. It specifies the 'Accept' header for the request. ```python import requests response = requests.get( '/api/v2/config/ips/', headers={"Accept":"*/"}, ) data = ``` -------------------------------- ### XPath Selector Example Source: https://docs.bugbug.io/preventing-failed-tests/selectors An example of an XPath selector used to identify an element by its ID. ```text //*[@id=\"submit\"] ``` -------------------------------- ### List Available CLI Commands Source: https://docs.bugbug.io/integrations/api Use the 'help' command to discover all available commands and their usage. This is useful for understanding the CLI's capabilities. ```bash bugbug help ``` -------------------------------- ### Example Alert Payload Source: https://docs.bugbug.io/collaboration/alerts/sending-webhook This is an example of a JSON payload that is sent when an alert is triggered. It contains details about the test run, suite, and status. ```json [ { "object": "block", "type": "code-line", "isVoid": false, "data": {}, "nodes": [ { "object": "text", "leaves": [ { "object": "leaf", "text": "[", "marks": [] } ], "key": "pBik2zIL7dHd" } ], "key": "pXZV19eK2Fvn" }, { "object": "block", "type": "code-line", "isVoid": false, "data": {}, "nodes": [ { "object": "text", "leaves": [ { "object": "leaf", "text": " {", "marks": [] } ], "key": "YTHbNldFk53w" } ], "key": "5Ft1hjHhFjDB" }, { "object": "block", "type": "code-line", "isVoid": false, "data": {}, "nodes": [ { "object": "text", "leaves": [ { "object": "leaf", "text": " \"suiteRunId\": \"\",", "marks": [] } ], "key": "Gh6dJfi6AWRn" } ], "key": "S0SWnA34FMNN" }, { "object": "block", "type": "code-line", "isVoid": false, "data": {}, "nodes": [ { "object": "text", "leaves": [ { "object": "leaf", "text": " \"suiteRunUrl\": \"https://app.bugbug.io/.../runs-history/suites//\",", "marks": [] } ], "key": "yGach8LyUPCJ" } ], "key": "M0R8WqYu3PUp" }, { "object": "block", "type": "code-line", "isVoid": false, "data": {}, "nodes": [ { "object": "text", "leaves": [ { "object": "leaf", "text": " \"suiteId\": \"\",", "marks": [] } ], "key": "ELBk7LyUSOsP" } ], "key": "cBm9grcFCAO1" }, { "object": "block", "type": "code-line", "isVoid": false, "data": {}, "nodes": [ { "object": "text", "leaves": [ { "object": "leaf", "text": " \"suiteName\": \"'MAIN' Suite\",", "marks": [] } ], "key": "GkVQKCXBZ7t3" } ], "key": "pATQPZx9oMU4" }, { "object": "block", "type": "code-line", "isVoid": false, "data": {}, "nodes": [ { "object": "text", "leaves": [ { "object": "leaf", "text": " \"status\": \"failed\",", "marks": [] } ], "key": "AKbWfIheLsws" } ], "key": "pioI8Gnf6n7a" }, { "object": "block", "type": "code-line", "isVoid": false, "data": {}, "nodes": [ { "object": "text", "leaves": [ { "object": "leaf", "text": " \"started\": " "marks": [] } ], "key": "Q9fZZvStSfkR" } ], "key": "oV2K0dLGVYqS" } ] ``` -------------------------------- ### View Another Test Run's Details Source: https://docs.bugbug.io/integrations/api This example shows the output for a different test run, illustrating the format of test name and status reporting. ```text ℹ Test name: Test number 71 (testRunId: ba5e19d8-609d-4529-95f6-0c6179e59614) ✔ Status: ``` -------------------------------- ### Webhook Payload: Started Event Source: https://docs.bugbug.io/collaboration/alerts/sending-webhook This snippet shows the structure of a webhook payload when an alert is started. It includes a string identifier for the event. ```json { "event": "started", "timestamp": "{{started}}" } ``` -------------------------------- ### List Historical Test Runs Source: https://docs.bugbug.io/llms-full.txt Retrieves a paginated list of historical test runs. Supports filtering by start time and status, and sorting by start time. ```APIDOC ## GET /api/v2/testruns/ ### Description Returns a list of historical TestRuns. This endpoint allows for filtering by date, status, and test ID, as well as pagination and ordering. ### Method GET ### Endpoint /api/v2/testruns/ ### Parameters #### Query Parameters - **ordering** (string) - Optional - Sort list by param. Allowed values: "-started", "started". - **page** (integer) - Optional - A page number within the paginated result set. - **page_size** (integer) - Optional - Number of results to return per page. - **started_after** (string) - Optional - Filter by start time (ISO 8601 format). - **started_before** (string) - Optional - Filter by end time (ISO 8601 format). - **status** (string) - Optional - Filter by test run status. Allowed values: "auto_retrying", "error", "failed", "initialized", "passed", "paused", "queued", "recording", "running", "skipped", "stopped". - **testId** (string) - Optional - Filter by test ID (UUID format). - **test_id** (string) - Optional - Filter by test ID (UUID format). ### Response #### Success Response (200) - **count** (integer) - The total number of test runs. - **next** (string) - URL for the next page of results, or null if none. - **previous** (string) - URL for the previous page of results, or null if none. - **results** (array) - An array of V2TestRun objects. ### Response Example { "count": 100, "next": "/api/v2/testruns/?page=2", "previous": null, "results": [ { "browserName": "chrome", "browserVersion": "100.0.0", "browserHeight": 1080, "browserWidth": 1920, "stepsRuns": "...", "userId": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "duration": "0h 1m 30s", "ended": "2023-10-27T10:00:00Z", "errorCode": null, "extensionVersion": "1.2.3", "id": "f1e2d3c4-b5a6-7890-1234-567890abcdef", "name": "Homepage Test", "osName": "Windows", "queued": "2023-10-27T09:58:00Z", "runMode": "server", "runProfileId": "1234abcd-ef01-2345-6789-012345abcdef", "screenSizeType": "desktop", "sequence": 1, "started": "2023-10-27T09:58:30Z", "status": "passed", "suiteRunId": "abcdef01-2345-6789-abcd-ef0123456789", "testId": "09876543-21fe-dcba-9876-543210fedcba", "triggeredBy": "user", "webappUrl": "https://example.com" } ] } #### Error Response (401) - **description**: Authentication credentials were missing or invalid. ``` -------------------------------- ### Run Entire Test Suite via CLI Source: https://docs.bugbug.io/integrations/api Execute an entire test suite by copying the provided command and running it in your terminal. The SUITE_ID will differ from the example. ```bash bugbug run --suite-id 699b47d9622345b4808848ecebb40673 ``` -------------------------------- ### Webhook Response Structure Source: https://docs.bugbug.io/integrations/webhooks If the request is valid, BugBug starts the run and returns a 200 OK response. The response contains fields detailing the started run. ```json { "id": "run-12345", "url": "https://example.com", "name": "My Test Run", "status": "running", "createdAt": "2023-10-27T10:00:00Z" } ``` -------------------------------- ### Example of Split User Paths into Independent Tests Source: https://docs.bugbug.io/in-depth-guides/beginners-tutorial-to-automation-testing Demonstrates how to break down a long test case into two independent, shorter tests. This approach improves maintainability and test execution speed. ```text Test name,Steps Landing page features,go to landing page URL click "features" assert all the features Landing page contact,go to landing page URL click "contact" assert contact information ``` -------------------------------- ### Example Test Accounts Spreadsheet Source: https://docs.bugbug.io/in-depth-guides/beginners-tutorial-to-automation-testing This table outlines a structure for managing test accounts, including email, password, type, and specific parameters for each account. It's useful for organizing dedicated test users with varying configurations. ```text Email,Password,Type,Parameters test-automation-standard@xyz.com,qwe123qwe,Business,User with default configuration for business accounts test-automation-trial@xyz.com,asd4rftha,Personal,Trial account test-automation-subscribed@xyz.com,46dghbn90,Business,Paying user, with a subscription active ``` -------------------------------- ### Sending a Basic Webhook Source: https://docs.bugbug.io/collaboration/alerts/sending-webhook This snippet demonstrates how to send a simple webhook notification using Python's requests library. Ensure you have the library installed (`pip install requests`). ```python import requests import json webhook_url = "YOUR_WEBHOOK_URL" data = { "message": "Hello from your application!", "level": "info" } headers = { "Content-Type": "application/json" } try: response = requests.post(webhook_url, data=json.dumps(data), headers=headers) response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx) print(f"Webhook sent successfully! Status code: {response.status_code}") except requests.exceptions.RequestException as e: print(f"Error sending webhook: {e}") ``` -------------------------------- ### Run Mode Configuration Source: https://docs.bugbug.io/collaboration/alerts/sending-webhook Configure the run mode for alerts. Use 'cloud', 'local', or 'recording' as appropriate. ```text {{runMode}} ```