Registry / testing / newman-reporter-ctrf-json

newman-reporter-ctrf-json

JSON →
library0.0.13jsnpmunverified

newman-reporter-ctrf-json is a test reporter for Postman Newman, designed to output test execution results in the Common Test Report Format (CTRF) JSON specification. This standardized format enables machine-readable and consistent reporting across diverse testing tools and platforms, significantly streamlining integration into CI/CD pipelines for centralized test result analysis. Currently at version 0.0.13, the package is in early development, with iterative updates addressing bug fixes and minor enhancements, as indicated by recent `0.0.13-next-1` and `0.0.13` releases. Its primary advantage lies in providing a structured, interoperable JSON output, distinct from Newman's default proprietary JSON format, making it ideal for systems that consume CTRF.

npm install newman-reporter-ctrf-json
INSTALL
IMPORT
SIG · NEWMAN-REPORTER-CT
N
newman-reporter-ctrf-json
testingjavascriptv0.0.13
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CTRFReporter
import CTRFReporter from 'newman-reporter-ctrf-json';
import { CTRFReporter } from 'newman-reporter-ctrf-json';
For programmatic use, the reporter is typically imported as a default export (a constructor function) for Newman's API, rather than a named export. Most users will interact via the Newman CLI and not directly import this package.
CTRFReporter (CJS)
const CTRFReporter = require('newman-reporter-ctrf-json');
CommonJS import for environments that do not support ES Modules. This pattern aligns with how many Node.js plugins, especially reporters, expose their primary interface.
Newman programmatic usage
newman.run({ reporters: ['cli', 'ctrf-json'], reporter: { 'ctrf-json': { export: 'report.json' } } });
The most common programmatic use involves specifying 'ctrf-json' as a string in the `reporters` array of Newman's `run` options, letting Newman handle the internal loading of the reporter.

This quickstart demonstrates how to programmatically run a Postman collection using Newman and generate a CTRF JSON report. It shows how to specify the `ctrf-json` reporter and its output path within a Node.js script.

import newman from 'newman'; import path from 'path'; import fs from 'fs'; // Create dummy Postman collection and environment files for a runnable example const collectionPath = path.join(__dirname, 'postman_collection.json'); const environmentPath = path.join(__dirname, 'postman_environment.json'); const ctrfOutputPath = path.join(__dirname, 'ctrf-report.json'); if (!fs.existsSync(collectionPath)) { fs.writeFileSync(collectionPath, JSON.stringify({ info: { _postman_id: 'a1b2c3d4-e5f6-7890-1234-567890abcdef', name: 'Example Test Collection' }, item: [ { name: 'Get Request', request: { url: 'https://postman-echo.com/get?foo=bar', method: 'GET' }, event: [{ listen: 'test', script: { exec: ['pm.test("Status code is 200", function () { pm.response.to.have.status(200); });'], type: 'text/javascript' } }] }, { name: 'Post Request', request: { url: 'https://postman-echo.com/post', method: 'POST', body: { mode: 'raw', raw: '{"key":"value"}', options: { raw: { language: 'json' } } } }, event: [{ listen: 'test', script: { exec: ['pm.test("Response has key", function () { pm.expect(pm.response.json().data).to.have.property("key"); });'], type: 'text/javascript' } }] } ] }, null, 2)); } if (!fs.existsSync(environmentPath)) { fs.writeFileSync(environmentPath, JSON.stringify({ id: 'fedcba98-7654-3210-fedc-ba9876543210', name: 'Test Environment', values: [{ key: 'baseUrl', value: 'https://postman-echo.com', enabled: true }] }, null, 2)); } console.log('Running Newman with CTRF JSON Reporter...'); // Run Newman programmatically with the CTRF JSON reporter newman.run({ collection: collectionPath, environment: environmentPath, reporters: ['cli', 'ctrf-json'], // Use 'cli' for console output, 'ctrf-json' for the report reporter: { 'ctrf-json': { export: ctrfOutputPath // Specify the output path for the CTRF report } } }, function (err, summary) { if (err) { console.error('Collection run encountered an error:', err); } if (summary && summary.run && summary.run.error) { console.error('Collection run failed:', summary.run.error); } else { console.log('Collection run completed successfully!'); if (fs.existsSync(ctrfOutputPath)) { const report = fs.readFileSync(ctrfOutputPath, 'utf8'); console.log(`CTRF report generated at ${ctrfOutputPath}. First 200 characters:\n${report.substring(0, 200)}...`); } else { console.warn('CTRF report file not found, check reporter configuration or Newman execution.'); } } });
Debug
Known issues
breakingAs the package is in early-stage development (v0.0.x), the API and output CTRF schema are subject to change without major version bumps. Future minor or patch releases may introduce breaking changes to the report structure or internal workings.
fix
Regularly review the package's GitHub repository and changelog for updates. Consider pinning to exact patch versions in production environments to mitigate unexpected changes, and thoroughly test after upgrading.
affects: >=0.0.1
gotchaThe reporter generates output strictly conforming to the Common Test Report Format (CTRF) specification. Users must be familiar with the CTRF schema to effectively parse, analyze, and utilize the generated JSON report in their systems.
fix
Refer to the official CTRF specification documentation to understand the structure and semantics of the generated test report.
affects: >=0.0.1
gotchaFor the `newman-reporter-ctrf-json` to be discoverable and usable by the Newman CLI, `newman` must be installed as a peer dependency, either globally or locally within your project.
fix
Ensure `newman` is installed: `npm install -g newman` for global CLI use, or `npm install --save-dev newman` if used within a project's `package.json` scripts or programmatic API.
affects: >=0.0.1
Errors
Common errors & fixes
Error: Reporter 'ctrf-json' not found.
The `newman-reporter-ctrf-json` package is either not installed, or Newman cannot locate it in its search paths (e.g., `node_modules` for local installation, or global `node_modules` for global installation).
fix
Install the reporter package. For global Newman usage: `npm install -g newman newman-reporter-ctrf-json`. For local project usage: `npm install --save-dev newman newman-reporter-ctrf-json`.
CTRF report file not generated at specified path.
This can be due to an incorrect output path, insufficient file permissions for the specified directory, or an error during Newman's test execution that prevented the reporter from finalizing and writing the file.
fix
Verify that the path provided to `--reporter-ctrf-json-export` (CLI) or `reporter['ctrf-json'].export` (programmatic API) is valid and that the process has write permissions for that directory. Check Newman's console output for any preceding errors.
Upgrade
Version history
0.0.13latest on npm
Audit
Dependencies
newmanrequiredThis package is a reporter for Newman and requires it to execute tests.
Agent activity
12 hits · last 30 days
node
12
Resources
newman-reporter-ctrf-json — npm install newman-reporter-ctrf-json · libregistry