Testomatio Reporter

repository·2.x·Indexed 40 days ago

https://github.com/testomatio/reporter

Client and adapters for reporting test results to Testomat.io. Supports integration with CodeceptJS 3.7+, Playwright, Vitest, Newman, and WebdriverIO (v7+ or v8+). Includes a CLI for test execution, Allure report import capabilities, and a webdriver-hooks-enhancer for improved failure handling in WebdriverIO.

Tokens
43.4K
Snippets
175
Records
220
Agent score
100%

What's inside Testomatio

  1. Understand the Markdown report layout

    2.x

    The generated Markdown report includes several structured sections:

    • Header: Displays the title and overall run status.
    • Summary table: Totals for passed, failed, skipped, todo, and flaky tests.
    • Run Metadata table: Details including status, run id, run URL, start time, duration, and parallel flag.
    • Description: Renders Markdown content from the shared pipe store (e.g., via coverageDescription or runParams.description).
    • Configuration: A table of key/value pairs if client.createRun({ configuration: { ... } }) was called (e.g., browser, shard).
    • Tests (grouped by suite): Each test entry contains:
      • A meta table (Status, Retries, Duration, Test ID).
      • Steps rendered as a bullet list (supports CodeceptJS-style <br>-joined strings or nested step trees).
      • Message rendered as a blockquote.
      • Stack Trace and Logs rendered as fenced code blocks.
      • Artifacts inside a collapsible <details> block. Images render inline; other files are provided as links. (Note: Trace ZIPs are filtered out; local files use file:// URLs, while remote artifacts use their original URL).
  2. Use the --format flag for machine-readable output

    2.x

    The --format flag enables machine-readable mode, which is essential for piping output or capturing it in shell variables. In this mode, the startup banner is suppressed, and informational logs are routed to stderr (with the info level lowered to WARN), ensuring stdout contains only the requested data.

    Key behaviors:

    • Clean stdout: Only the requested payload (e.g., a Run ID or JSON object) is written to stdout. Warnings and errors are sent to stderr.
    • JSON Logging: Using --format json also makes reporter messages machine-readable. Every log entry is printed to stderr as a single JSON object per line. This is useful for diagnosing failures without text scraping.
    • Debugging: If you need to see progress logs while using --format, set the environment variable TESTOMATIO_LOG_LEVEL=INFO to bring them back on stderr.

    Example: Capturing JSON logs for error analysis

    npx @testomatio/reporter start --format json 2>errors.log
  3. Use Report ID (rid) for cross-platform testing

    2.x

    The rid (Report ID) parameter allows you to report the same test multiple times within a single run. This is useful when running the same test across different environments (e.g., Windows vs Linux, or different browsers) where you want each execution to be recorded separately even if they share the same test_id.

    By providing a unique rid for each environment, Testomat.io recognizes them as distinct executions of the same test case.

    {
      "tests": [
        {
          "title": "Should login successfully",
          "status": "passed",
          "test_id": "@Ta0b0c0d0",
          "rid": "chrome-login:windows",
          "run_time": 0.5
        },
        {
          "title": "Should login successfully",
          "status": "failed",
          "test_id": "@Ta0b0c0d0",
          "rid": "chrome-login:linux",
          "run_time": 0.6
        }
      ]
    }
  4. Deduplicate retried tests via historyId

    2.x

    The reporter automatically deduplicates retried tests. If a single test is run multiple times, the results are combined into one Testomat.io test entry based on the Allure historyId.

    • Status: The final status reflects the last attempt. If the final attempt passes but earlier attempts failed, the test is marked as failed with combined failure information.
    • Failure Info: If any retry attempt fails, all failure messages and stack traces from all failed attempts are combined into the report.
  5. Upload file attachments as artifacts

    2.x

    The reporter automatically detects and uploads files as artifacts if they are referenced in the test output using the file:// URL pattern. This works across different platforms and supports the following formats:

    • Unix/Linux (absolute): file:///absolute/path/to/file.png
    • Unix/Linux (relative): file://relative/path/to/file.png
    • Windows (backslashes): file:/C:\Users\username\path\to\file.png
    • Windows (forward slashes): file://C:/Users/username/path/to/file.png

    In NUnit, if the XML report contains a <ResultFiles> section (common in Playwright DotNet), all items within it will also be automatically uploaded.

  6. Understand the Debug File Format (JSONL)

    2.x

    The debug file uses JSONL (JSON Lines) format. Unlike a standard JSON array, each line in the file is a standalone, valid JSON object. This allows for streaming processing and incremental writing of test data.

    Entry Structure

    Every entry must include a time field t representing the time elapsed since the previous action.

    {
      "t": "+150ms"
      // ... action-specific fields
    }

    Time Field (t) Format

    • Format: "+{milliseconds}ms" (e.g., "+150ms", "+2.5s")
    • Represents the duration passed since the previous entry.
    {"t":"+0ms","datetime":"2024-01-15T10:30:00.000Z","timestamp":1705315800000}
    {"t":"+5ms","data":"variables","testomatioEnvVars":{"TESTOMATIO":"abc123"}}
    {"t":"+10ms","action":"createRun","params":{"title":"Test Run"}}
  7. Link Allure results to existing Testomat.io cases using @TmsLink

    2.x

    To prevent duplicate test creation and instead update existing cases, use the @TmsLink annotation in your test code. The reporter identifies these links in the Allure JSON and maps them to the corresponding Testomat.io test IDs.

    Usage in Java/Kotlin

    @TmsLink("1a2b3c4d")
    @Test
    void testLogin() { ... }

    You can also link to multiple cases:

    @TmsLinks({ @TmsLink("00056731"), @TmsLink("00056729") })
    @Test
    void testCheckout() {
    }

    Key Behaviors

    • ID Format: Testomat.io IDs are exactly 8 characters. The reporter accepts bare IDs (1a2b3c4d) or markers like T1a2b3c4d or @T1a2b3c4d and normalizes them.
    • Fallback Mechanism: If a test has no test_id but has @TmsLink annotations, the first linked case is adopted as the test_id to match the existing case.
    • Invalid IDs: Non-8-character IDs (like JIRA keys or numeric Allure TestOps IDs) are ignored and will not match existing cases; these tests will be created as new entries.
  8. Understand Testomatio Run Types and reporting behavior

    2.x

    Testomatio supports different run modes that determine how automated tests and linked manual test cases appear in your final report. Choosing the right mode depends on whether you want to focus on automation results, manual test coverage, or a combination of both.

    Automated Run (Default)

    • Behavior: Creates an automated run. Automated tests are the main focus.
    • Reporting: Shows automated test execution results. Linked manual test cases appear as references but are not counted as executed tests in the report total.

    Manual Run

    • Behavior: Used when you want to report only manual test case execution. The automated test is completely hidden.
    • Reporting: Only the manual test cases linked via linkTest() appear in the report. This is useful when an automated test is simply verifying the status of manual test cases.

    Mixed Run

    • Behavior: Shows both automated and manual results as separate entities.
    • Reporting: Automated tests appear in the report, and any manual test cases linked via linkTest() also appear separately. This provides the most precise view of both automation and manual coverage in one report.
    Run TypeAutomated TestsManual TestsTotal in Report
    Automated1 (with links)01
    Manual055
    Mixed156
  9. How @testomatio/webdriver-hooks-enhancer handles hook failures

    2.x

    By default, when a beforeEach hook fails in WebdriverIO, the execution stops and remaining tests are skipped. These skipped tests are typically NOT reported to Testomatio, leading to incomplete reports.

    This package solves this by:

    1. Tracking beforeEach hook failures per suite.
    2. Parsing spec files using AST (Abstract Syntax Tree) to identify all test titles.
    3. Reporting all tests (including those that would normally be skipped) as failed when a beforeEach hook failure is detected. This includes support for parametrized tests.
  10. Link test results to existing Testomat.io tests

    2.x

    You can link test results to existing tests in Testomat.io using the tid:// pattern in your test output. Use the 8-character test ID from Testomat.io (excluding the @T prefix from the URL).

    Pattern: tid://@T{test_id}

    Methods of linking:

    1. Test Output: Print tid://@T8acca9eb to stdout/console during test execution.
    2. Test Name: Add the ID to the test name (e.g., test name @T8acca9eb).
    3. Suite ID: Use @S{suite_id} to place a test inside a specific suite (e.g., test name @S1428a8fa).
    4. Source Code Comments: For supported languages, add the ID as a comment in the test body (e.g., // @T8acca9eb).
    <testcase name="User Registration Test" classname="UserTests">
      <system-out><![CDATA[
    Starting user registration test
    tid://@T8acca9eb
    User registration completed successfully
      ]]></system-out>
    </testcase>
  11. Choose between Public and Private Artifact Access

    2.x

    Testomat.io supports two privacy modes for artifacts:

    1. Public Access (Default): Artifacts are uploaded with public-read permissions. Files are accessible via a permanent public URL. This is ideal for displaying images directly in Testomat.io, GitHub, or GitLab Pipes.

    2. Private Access: Artifacts are stored securely. To use this mode:

      • Set the environment variable TESTOMATIO_PRIVATE_ARTIFACTS=1.
      • Provide the S3 credentials in the Testomat.io Application under Settings > Artifacts so the application can generate pre-signed links.
      • Links generated in this mode are pre-signed and expire automatically after 10 minutes.
  12. Configure portable local artifacts for HTML reports

    2.x

    When using CI artifact viewers (like Jenkins) that cannot access file:// links, you need to ensure your HTML report is 'portable'.

    By default, if S3 uploading is not configured, the pipe copies artifacts (like screenshots) to an artifacts/ folder next to the HTML report and uses relative links (e.g., ./artifacts/failure.png).

    To ensure portability even when S3 artifact uploading is configured, set: TESTOMATIO_HTML_REPORT_COPY_ARTIFACTS=1.

    Note: When using portable links, you must archive or publish the entire report folder (e.g., html-report/**), not just the single .html file, so that the artifacts/ directory is included.