{"id":15341,"library":"jasmine-ctrf-json-reporter","title":"Jasmine CTRF JSON Reporter","description":"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.","status":"active","version":"0.0.7","language":"javascript","source_language":"en","source_url":"https://github.com/ctrf-io/jasmine-ctrf-json-reporter","tags":["javascript","ctrf","common-test-report-format","test-reporting","test-results","testing","json","ci","jasmine","typescript"],"install":[{"cmd":"npm install jasmine-ctrf-json-reporter","lang":"bash","label":"npm"},{"cmd":"yarn add jasmine-ctrf-json-reporter","lang":"bash","label":"yarn"},{"cmd":"pnpm add jasmine-ctrf-json-reporter","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Used to instantiate the reporter. The CJS `require` example implies a default export.","wrong":"const CtrfReporter = require('jasmine-ctrf-json-reporter');","symbol":"CtrfReporter","correct":"import CtrfReporter from 'jasmine-ctrf-json-reporter';"},{"note":"Provides the `extra` function for attaching custom metadata to individual test results. This is a named export.","wrong":"import ctrf from 'jasmine-ctrf-json-reporter';","symbol":"ctrf","correct":"import { ctrf } from 'jasmine-ctrf-json-reporter';"},{"note":"Type import for configuring reporter options in TypeScript projects. Do not use for runtime import.","wrong":"import { ReporterOptions } from 'jasmine-ctrf-json-reporter';","symbol":"ReporterOptions","correct":"import type { ReporterOptions } from 'jasmine-ctrf-json-reporter';"}],"quickstart":{"code":"import CtrfReporter, { ctrf } from 'jasmine-ctrf-json-reporter';\n\n// In your Jasmine helper file (e.g., spec/support/jasmine.js or .ts)\n// It's recommended to configure the reporter here.\njasmine.getEnv().addReporter(\n  new CtrfReporter({\n    outputFile: 'my-custom-ctrf-report.json', // Optional: Custom output file name\n    outputDir: 'reports/ctrf-output',       // Optional: Custom output directory\n    appName: 'MyFeatureApp',                // Optional: Application name\n    appVersion: '1.2.3',                    // Optional: Application version\n    osPlatform: process.env.OS_PLATFORM ?? 'web', // Dynamically set OS platform\n    osRelease: process.env.OS_RELEASE ?? 'latest',\n    buildName: 'CI-Pipeline-Build',         // Optional: Build name\n    buildNumber: process.env.BUILD_NUMBER ?? 'unknown' // Dynamic build number\n  })\n);\n\n// Example of usage within a test file (e.g., spec/my-feature.spec.ts)\ndescribe('User Management Module', () => {\n  it('should successfully register a new user', () => {\n    // Attach custom metadata to this specific test result\n    ctrf.extra({ owner: 'user-auth-team', priority: 'high', testId: 'UM-001' });\n    // ... actual test logic for user registration ...\n    expect(true).toBe(true); // Placeholder for actual test\n  });\n\n  it('should validate email format during registration', () => {\n    // This test might not need extra metadata\n    expect(false).toBe(false); // Another placeholder test\n  });\n});","lang":"typescript","description":"Demonstrates how to install the reporter, configure it in Jasmine, and use the `ctrf.extra()` function to add custom metadata to individual test results."},"warnings":[{"fix":"Pin to exact versions in `package.json` for production environments (`\"jasmine-ctrf-json-reporter\": \"0.0.x\"`) and manually review releases, or use a tilde `~` to allow patch updates only.","message":"This package is still in early development (v0.0.x). While efforts are made for stability, the API may undergo breaking changes in minor versions. Always review the changelog when updating.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Place `jasmine.getEnv().addReporter(new CtrfReporter(...));` in your main Jasmine configuration or helper file that is loaded before tests run.","message":"The reporter is configured by adding it directly to the Jasmine environment (`jasmine.getEnv().addReporter()`), not through `jasmine.json` or other configuration files. Ensure this line is present in your `spec/support/jasmine.js` or similar setup file.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Explicitly set `outputFile` and `outputDir` in the reporter options if you require a specific path, e.g., `{ outputFile: 'test-results.json', outputDir: 'artifacts' }`.","message":"The `outputFile` and `outputDir` options have default values (`ctrf-report.json` and `ctrf/`). If these are not specified, the output will be generated in the default location. Ensure your CI/CD pipelines are aware of these defaults or configure custom paths explicitly.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure you have `npm install --save-dev jasmine-ctrf-json-reporter` and use `const CtrfReporter = require('jasmine-ctrf-json-reporter');` for CommonJS or `import CtrfReporter from 'jasmine-ctrf-json-reporter';` for ESM.","cause":"The `CtrfReporter` class was not imported or required correctly, or the module path is incorrect.","error":"ReferenceError: CtrfReporter is not defined"},{"fix":"Run `npm install --save-dev jasmine-ctrf-json-reporter` to add the package to your project.","cause":"The package has not been installed or is not accessible in the current environment.","error":"Error: Cannot find module 'jasmine-ctrf-json-reporter'"},{"fix":"Ensure your reporter setup code is run within a Jasmine test environment, typically in a helper file loaded by Jasmine before test execution.","cause":"This error typically occurs if you're trying to add the reporter outside of a context where `jasmine.getEnv()` is available, or if Jasmine itself isn't properly set up.","error":"TypeError: jasmine.getEnv(...).addReporter is not a function"},{"fix":"Verify the reporter is correctly added to `jasmine.getEnv().addReporter()` and check the `outputDir` and `outputFile` options. Ensure the test run completes without errors that might prevent the report from being written.","cause":"The reporter did not execute, or the output directory/file name was customized and not found at the expected location.","error":"File 'ctrf/ctrf-report.json' not found after tests complete."}],"ecosystem":"npm"}