CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-jasmine-reporters

A collection of JavaScript reporter classes for the Jasmine BDD testing framework that output test results in various formats including JUnit XML, NUnit XML, TAP, TeamCity, AppVeyor, and Terminal

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

ci-integration.mddocs/

CI Integration

Cloud-based CI system integration that posts test results to external APIs during test execution. Provides real-time test result reporting to CI platforms for immediate feedback and build status updates.

Capabilities

AppVeyor Reporter

Posts test results to AppVeyor build system via HTTP API with configurable batching and output formatting. Requires AppVeyor environment to be properly configured with API endpoint information.

/**
 * Creates an AppVeyor reporter instance that posts results to AppVeyor API
 * @param options - Configuration options for AppVeyor integration
 * @returns Reporter instance implementing Jasmine reporter interface
 */
function AppVeyorReporter(options?: AppVeyorOptions): Reporter;

interface AppVeyorOptions {
  /** Spec batch size to report to AppVeyor, higher values reduce API calls (default: 50) */
  batchSize?: number;
  /** Verbosity level 0-2+, controls logging output (default: 0) */
  verbosity?: number;
  /** Enable colored console output for logging (default: true) */
  color?: boolean;
}

Environment Requirements:

The AppVeyor reporter requires the APPVEYOR_API_URL environment variable to be set by the AppVeyor build environment. This is automatically provided when running in AppVeyor CI.

Usage Examples:

// Basic AppVeyor integration with default settings
const appveyorReporter = new jasmineReporters.AppVeyorReporter();
jasmine.getEnv().addReporter(appveyorReporter);

// Custom batch size and verbose logging
const appveyorReporter = new jasmineReporters.AppVeyorReporter({
    batchSize: 25,
    verbosity: 2,
    color: true
});

// High-throughput configuration for large test suites
const appveyorReporter = new jasmineReporters.AppVeyorReporter({
    batchSize: 100,
    verbosity: 0,
    color: false
});

API Integration Details

The AppVeyor reporter communicates with the AppVeyor Test API to report test results in real-time.

/**
 * Internal API configuration derived from environment variables
 */
interface AppVeyorApi {
  /** API host extracted from APPVEYOR_API_URL */
  host: string;
  /** API port extracted from APPVEYOR_API_URL */  
  port: string;
  /** API endpoint path for batch test reporting */
  endpoint: string; // "/api/tests/batch"
}

/**
 * Test result format sent to AppVeyor API
 */
interface AppVeyorTestResult {
  /** Full qualified test name including suite and spec names */
  testName: string;
  /** Testing framework identifier */
  testFramework: "jasmine2";
  /** Test execution duration in milliseconds */
  durationMilliseconds: number;
  /** Test outcome using AppVeyor terminology */
  outcome: "Passed" | "Failed" | "Skipped" | "Ignored" | "None";
  /** Error message from first failed expectation (if any) */
  ErrorMessage?: string;
  /** Stack trace from first failed expectation (if any) */
  ErrorStackTrace?: string;
}

HTTP Request Handling

The reporter uses Node.js http module to send POST requests to the AppVeyor API.

Request Configuration:

  • Method: POST
  • Content-Type: application/json
  • Endpoint: /api/tests/batch
  • Body: JSON array of test results

Error Handling:

  • Network errors are logged but don't interrupt test execution
  • API response errors are logged with status codes and headers when verbosity > 1
  • Failed requests don't retry automatically

Batching Strategy

Tests are batched to optimize API performance and reduce network overhead.

Batching Behavior:

  • Results accumulate until batch size is reached
  • Batch is sent immediately when limit is exceeded
  • Remaining results are sent when all tests complete (jasmineDone)
  • Each batch is sent as a separate HTTP request

Batch Size Considerations:

  • Small batches (10-25): More frequent updates, higher API overhead
  • Medium batches (50-100): Good balance for most test suites
  • Large batches (100+): Fewer API calls, delayed feedback

Logging and Verbosity

Configurable logging provides insight into reporter operation and API communication.

Verbosity Levels:

  • 0 (Silent): No logging output
  • 1 (Info): Basic operation messages (batch sending)
  • 2+ (Debug): Detailed API communication (status codes, headers, response bodies)

Color Support:

  • Magenta: Batch posting messages
  • Yellow: API response details
  • Red: Error messages

Test Result Mapping

Jasmine test states are mapped to AppVeyor outcome terminology:

Jasmine StatusAppVeyor OutcomeDescription
"passed""Passed"Test executed successfully
"failed""Failed"Test failed with assertion errors
"pending""Skipped"Test skipped with xit() or pending()
"disabled""Ignored"Test disabled with xdescribe() or filtered

Reporter Lifecycle Methods

/** Called when a test spec starts - records start time */
specStarted(spec: Spec): void;

/** Called when a test spec completes - processes result and adds to batch */
specDone(spec: Spec): void;

/** Called when all tests complete - sends remaining batch results */
jasmineDone(): void;

State Management:

  • Internal spec tracking with start/end times for duration calculation
  • Unreported specs queue for batching
  • Automatic batch flushing when size threshold reached

Integration Examples

AppVeyor Configuration (appveyor.yml):

test_script:
  - npm test

environment:
  # APPVEYOR_API_URL is automatically set by AppVeyor

Test Runner Integration:

// spec/support/jasmine.json or similar
const reporters = require('jasmine-reporters');

if (process.env.APPVEYOR) {
    const appveyorReporter = new reporters.AppVeyorReporter({
        batchSize: 50,
        verbosity: 1
    });
    jasmine.getEnv().addReporter(appveyorReporter);
}

Combined with Other Reporters:

// Use AppVeyor reporter alongside terminal output
const reporters = require('jasmine-reporters');

jasmine.getEnv().addReporter(new reporters.TerminalReporter({
    verbosity: 2,
    color: true
}));

if (process.env.APPVEYOR) {
    jasmine.getEnv().addReporter(new reporters.AppVeyorReporter({
        batchSize: 75,
        verbosity: 0  // Silent to avoid duplicate output
    }));
}

docs

ci-integration.md

console-reporters.md

index.md

xml-reporters.md

tile.json