Jasmine CTRF JSON Reporter

0.0.7 · active · verified Tue Apr 21

jasmine-ctrf-json-reporter is a utility package that provides a Jasmine test results reporter, specifically designed to output test reports conforming to the Common Test Report Format (CTRF) schema. This package addresses the challenge of inconsistent test report formats across various programming languages and testing frameworks by offering a standardized output. The current stable version is `0.0.7`. While a formal release cadence is not explicitly stated, the project demonstrates ongoing maintenance with recent dependency updates and minor version bumps. Its primary differentiator is its strict adherence to the CTRF open standard, which enables uniform validation, merging, comparison, and analysis of test results, regardless of the underlying testing tool or language. This consistency significantly simplifies integration into CI/CD pipelines and provides a universal reporting schema that facilitates better programmatic analysis of test outcomes.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to install the reporter, configure it in Jasmine, and use the `ctrf.extra()` function to add custom metadata to individual test results.

import CtrfReporter, { ctrf } from 'jasmine-ctrf-json-reporter';

// In your Jasmine helper file (e.g., spec/support/jasmine.js or .ts)
// It's recommended to configure the reporter here.
jasmine.getEnv().addReporter(
  new CtrfReporter({
    outputFile: 'my-custom-ctrf-report.json', // Optional: Custom output file name
    outputDir: 'reports/ctrf-output',       // Optional: Custom output directory
    appName: 'MyFeatureApp',                // Optional: Application name
    appVersion: '1.2.3',                    // Optional: Application version
    osPlatform: process.env.OS_PLATFORM ?? 'web', // Dynamically set OS platform
    osRelease: process.env.OS_RELEASE ?? 'latest',
    buildName: 'CI-Pipeline-Build',         // Optional: Build name
    buildNumber: process.env.BUILD_NUMBER ?? 'unknown' // Dynamic build number
  })
);

// Example of usage within a test file (e.g., spec/my-feature.spec.ts)
describe('User Management Module', () => {
  it('should successfully register a new user', () => {
    // Attach custom metadata to this specific test result
    ctrf.extra({ owner: 'user-auth-team', priority: 'high', testId: 'UM-001' });
    // ... actual test logic for user registration ...
    expect(true).toBe(true); // Placeholder for actual test
  });

  it('should validate email format during registration', () => {
    // This test might not need extra metadata
    expect(false).toBe(false); // Another placeholder test
  });
});

view raw JSON →