Registry / testing / karma-cucumber-reporter

karma-cucumber-reporter

JSON →
library1.0.4jsnpmunverified

karma-cucumber-reporter is a specialized Karma plugin designed to transform test results from the Karma test runner into the Cucumber JSON format. This output is primarily intended for consumption by external tools like `cucumber-reporting` to generate comprehensive BDD-style reports. The current stable version is 1.0.4, suggesting a mature and stable state rather than active, rapid development. Its key differentiator lies in its strict requirement for a specific test structure: top-level `describe('PREFIX FEATURE', ...)` and nested `describe('SCENARIO NAME', ...)` blocks, which allows it to accurately map Karma's test outcomes to Cucumber features and scenarios. It integrates seamlessly into Karma's configuration, writing the resulting JSON to a specified file or standard output.

npm install karma-cucumber-reporter
INSTALL
IMPORT
SIG · KARMA-CUCUMBER-REP
K
karma-cucumber-reporter
testingjavascriptv1.0.4
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.

karma-cucumber-reporter plugin
require('karma-cucumber-reporter')
import { KarmaCucumberReporter } from 'karma-cucumber-reporter';
This package is a Karma plugin and is configured by directly requiring it in the `plugins` array of `karma.conf.js`. It does not export symbols for direct import or instantiation.
reporters configuration
reporters: ['progress', 'cucumber']
The reporter is enabled by adding 'cucumber' to the `reporters` array in your `karma.conf.js`.
cucumberReporter options
cucumberReporter: { out: './report.json', prefix: 'MyApp' }
Configuration options like `out` (output file path) and `prefix` (to filter tests) are set under the `cucumberReporter` property in `karma.conf.js`.

This quickstart demonstrates how to install and configure `karma-cucumber-reporter` in `karma.conf.js`. It includes an example test file structured with the required `PREFIX FEATURE` and `SCENARIO` `describe` blocks, showing how to produce a `cucumber-report.json` output file compatible with Cucumber reporting tools.

npm install -D karma karma-jasmine karma-chrome-launcher karma-cucumber-reporter // karma.conf.js module.exports = function(config) { config.set({ frameworks: ['jasmine'], files: [ 'test/**/*.spec.js' ], reporters: ['progress', 'cucumber'], plugins: [ 'karma-jasmine', 'karma-chrome-launcher', require('karma-cucumber-reporter') ], browsers: ['ChromeHeadless'], singleRun: true, autoWatch: false, cucumberReporter: { out: './cucumber-report.json', // Output file for the Cucumber JSON report prefix: 'FeaturePrefix' // Prefix to identify features for reporting } }); }; // test/example.spec.js describe('FeaturePrefix MyApplication Feature', function () { describe('Scenario: As a user, I can log in successfully', function () { it('Given I am on the login page', function () { expect(true).toBe(true); // Placeholder for actual test logic }); it('When I enter valid credentials', function () { expect('username').toEqual('username'); expect('password').toEqual('password'); }); it('Then I should be redirected to the dashboard', function () { expect(1 + 1).toBe(2); }); }); describe('Scenario: As an admin, I can manage users', function () { it('Given I am logged in as an admin', function () { expect(true).toBe(true); }); it('When I navigate to the user management section', function () { expect(true).toBe(true); }); it('Then I should see a list of users', function () { expect(false).not.toBe(true); }); }); });
Debug
Known issues
gotchaTests must adhere to a specific `describe` block syntax for features and scenarios. Features require `describe('PREFIX FEATURE_NAME', function() { ... })` and scenarios require a nested `describe('SCENARIO_NAME', function() { ... })` block. Tests not matching this structure will not be correctly reported.
fix
Structure your test files using outer `describe('YOUR_PREFIX Your Feature Name', ...)` and inner `describe('Your Scenario Name', ...)` blocks for all tests intended for the Cucumber report.
affects: >=1.0.0
gotchaThe `prefix` option in `cucumberReporter` configuration must exactly match the `PREFIX` string used in your test's top-level `describe` blocks (e.g., `describe('YOUR_PREFIX My Feature')`). Mismatched prefixes will cause tests to be excluded from the report.
fix
Ensure `cucumberReporter.prefix` in `karma.conf.js` is identical to the prefix used in your feature `describe` blocks in test files.
affects: >=1.0.0
gotchaEach feature `describe` block (e.g., `describe('PREFIX FEATURE_NAME', ...)`) must contain at least one nested scenario `describe` block (e.g., `describe('SCENARIO_NAME', ...)`). Empty feature blocks will not be correctly processed.
fix
Always include one or more `describe('Scenario Name', ...)` blocks within each `describe('Prefix Feature Name', ...)` block.
affects: >=1.0.0
Errors
Common errors & fixes
Error: No reporters found: cucumber
The 'cucumber' reporter string is missing from the `reporters` array in `karma.conf.js`, or the `karma-cucumber-reporter` plugin itself was not explicitly `require`d in the `plugins` array.
fix
Ensure `reporters: ['progress', 'cucumber']` and `plugins: [..., require('karma-cucumber-reporter')]` are correctly configured in `karma.conf.js`.
Cucumber report file is empty or missing after test run
The `out` option for `cucumberReporter` is not set, or tests do not match the required `prefix` or structural requirements for features and scenarios.
fix
Verify `cucumberReporter.out` is set to a valid file path (e.g., `./cucumber-report.json`) and that test `describe` blocks adhere to `describe('YOUR_PREFIX FEATURE_NAME', function() { describe('SCENARIO_NAME', function() { ... }); });` where `YOUR_PREFIX` matches the `cucumberReporter.prefix` option.
Tests run, but do not appear in the generated Cucumber report, or the report is malformed.
Test `describe` blocks do not follow the expected `PREFIX FEATURE` and `SCENARIO` nested structure, or the `prefix` option in `karma.conf.js` does not match the test `describe` block's prefix.
fix
Ensure your tests conform strictly to `describe('YourPrefix Your Feature Name', function() { describe('Your Scenario Name', function() { ... }); });` and that `cucumberReporter.prefix` in `karma.conf.js` exactly matches `YourPrefix`.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
karmarequiredThis package is a plugin for Karma and requires Karma to run.
Agent activity
2 hits · last 30 days
node
2
Resources
karma-cucumber-reporter — npm install karma-cucumber-reporter · libregistry