Registry / testing / cucumber-junit-xml-formatter

cucumber-junit-xml-formatter

JSON →
library0.7.1jsnpmunverified

A forked JUnit XML formatter for Cucumber that extends the default internal formatter from @cucumber/cucumber (v10+) by adding file name and line numbers to each test case. Current stable version is 0.7.1. Accepts a stream of Cucumber messages and outputs JUnit XML. Requires @cucumber/messages as a peer dependency. Distinguishes itself from the built-in formatter by including scenario source location, which aids in test report debugging and CI integration.

npm install cucumber-junit-xml-formatter
INSTALL
IMPORT
SIG · CUCUMBER-JUNIT-XML
C
cucumber-junit-xml-formatter
testingjavascriptv0.7.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import CucumberJunitXmlFormatter from 'cucumber-junit-xml-formatter'
import { CucumberJunitXmlFormatter } from 'cucumber-junit-xml-formatter'
The package exports a single default class; named import will fail.
default (CommonJS)
const CucumberJunitXmlFormatter = require('cucumber-junit-xml-formatter')
const { CucumberJunitXmlFormatter } = require('cucumber-junit-xml-formatter')
CommonJS require returns the default export as the entire module.
TypeScript type
import type CucumberJunitXmlFormatter from 'cucumber-junit-xml-formatter'
import { CucumberJunitXmlFormatterType } from 'cucumber-junit-xml-formatter'
TypeScript types are shipped and the class can be imported as a type.

Basic setup importing the formatter and piping messages to generate JUnit XML output.

import { Writable } from 'stream'; import CucumberJunitXmlFormatter from 'cucumber-junit-xml-formatter'; import { fromPaths } from '@cucumber/cucumber'; const outputStream = new Writable({ write(chunk, encoding, callback) { process.stdout.write(chunk); callback(); } }); const formatter = new CucumberJunitXmlFormatter({ stream: outputStream }); // Example: pipe cucumber messages (from @cucumber/cucumber runtime) into the formatter // The following assumes you have a message stream, e.g., from Cucumber's eventBroadcaster. // For simplicity, we skip actual message piping; refer to Cucumber docs. process.stdin .pipe(formatter); // Alternatively, if used with Cucumber runtime: // const { EventEmitter } = require('events'); // const eventBroadcaster = new EventEmitter(); // eventBroadcaster.on('envelope', envelope => formatter.write(envelope));
Debug
Known issues
gotchaThe formatter expects input as Cucumber messages (envelopes) not feature files directly.
fix
Pipe the output from Cucumber's message stream, e.g., using @cucumber/cucumber's formatters option or programmatic API.
affects: >=0.0.0
gotchaThis is a fork of the internal formatter; it may lag behind official updates or changes in @cucumber/messages.
fix
Check compatibility with your @cucumber/messages version; use peer dependency @cucumber/messages: * but test against known versions.
affects: >=0.0.0
deprecatedThe output format may change between minor versions as it's a community-maintained fork.
fix
Pin to exact version if you rely on specific XML formatting.
affects: <0.8.0
Errors
Common errors & fixes
TypeError: CucumberJunitXmlFormatter is not a constructor
Using named import instead of default import.
fix
Use default import: import CucumberJunitXmlFormatter from 'cucumber-junit-xml-formatter'
Cannot find module '@cucumber/messages'
Missing peer dependency @cucumber/messages.
fix
Install @cucumber/messages: npm install @cucumber/messages
Upgrade
Version history
0.7.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
cucumber-junit-xml-formatter — npm install cucumber-junit-xml-formatter · libregistry