CodeceptJS CTRF JSON Reporter
The `codeceptjs-ctrf-json-reporter` is a CodeceptJS plugin designed to save test results as a JSON file, strictly adhering to the Common Test Report Format (CTRF) standard. Currently at version `0.0.5`, this package aims to provide a consistent and universal reporting schema for CodeceptJS users, facilitating easier analysis and comparison of test outcomes across diverse testing tools and programming languages. While a specific release cadence is not yet established given its pre-1.0 status, it integrates seamlessly into CodeceptJS configurations. Its key differentiator is its commitment to the open-source CTRF specification, ensuring uniformity in test reports, which is crucial for modern CI/CD pipelines and cross-platform testing environments, offering a standardized approach where other tools often produce varied formats.
Common errors
-
Error: Cannot find module 'codeceptjs-ctrf-json-reporter'
cause The package `codeceptjs-ctrf-json-reporter` is not installed or the `require` path in `codeceptjs.config.js` is incorrect.fixEnsure the package is installed: `npm install --save-dev codeceptjs-ctrf-json-reporter`. Verify the `require` path in your CodeceptJS configuration matches the package name exactly. -
TypeError: Cannot read properties of undefined (reading 'ctrfJsonReporter')
cause The `plugins` configuration for `ctrfJsonReporter` is malformed or not correctly nested within the `plugins` object in `codeceptjs.config.js`.fixDouble-check your `codeceptjs.config.js` file to ensure the `ctrfJsonReporter` entry is correctly placed within the `plugins` object and follows the expected JavaScript/TypeScript object literal syntax.
Warnings
- gotcha The package is currently in a pre-1.0 development phase (version `0.0.5`). APIs and features may undergo significant changes in future minor or patch releases, potentially introducing breaking changes without major version bumps until a stable 1.0 release.
- gotcha The reporter's configuration is managed entirely through the `plugins` section of `codeceptjs.config.js`. Attempting to import or instantiate the reporter directly in test files or other support code is not the intended usage and will not integrate it with CodeceptJS's lifecycle.
Install
-
npm install codeceptjs-ctrf-json-reporter -
yarn add codeceptjs-ctrf-json-reporter -
pnpm add codeceptjs-ctrf-json-reporter
Imports
- CTRFJsonReporter (via config)
import { CTRFJsonReporter } from 'codeceptjs-ctrf-json-reporter'plugins: { ctrfJsonReporter: { require: 'codeceptjs-ctrf-json-reporter', enabled: true } } - CTRFJsonReporter (Class)
const CTRFJsonReporter = require('codeceptjs-ctrf-json-reporter');import CTRFJsonReporter from 'codeceptjs-ctrf-json-reporter';
- CTRFJsonReporterOptions (Type)
import type { CTRFJsonReporterOptions } from 'codeceptjs-ctrf-json-reporter';
Quickstart
npm install --save-dev codeceptjs-ctrf-json-reporter
// codecept.conf.js or codecept.conf.ts
plugins: {
ctrfJsonReporter: {
require: 'codeceptjs-ctrf-json-reporter',
enabled: true,
outputFile: 'my-ctrf-report.json', // Optional: Customize output file name
outputDir: 'reports/ctrf', // Optional: Customize output directory
appName: 'MyAwesomeApp', // Optional: Include environment info
appVersion: '1.2.3'
},
// ... other plugins ...
},
// To run your tests and generate the report
npx codeceptjs run