{"id":15349,"library":"karma-cucumber-reporter","title":"Karma Cucumber Reporter","description":"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.","status":"maintenance","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/akullpp/karma-cucumber-reporter","tags":["javascript","karma","testing","cucumber"],"install":[{"cmd":"npm install karma-cucumber-reporter","lang":"bash","label":"npm"},{"cmd":"yarn add karma-cucumber-reporter","lang":"bash","label":"yarn"},{"cmd":"pnpm add karma-cucumber-reporter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a plugin for Karma and requires Karma to run.","package":"karma","optional":false}],"imports":[{"note":"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.","wrong":"import { KarmaCucumberReporter } from 'karma-cucumber-reporter';","symbol":"karma-cucumber-reporter plugin","correct":"require('karma-cucumber-reporter')"},{"note":"The reporter is enabled by adding 'cucumber' to the `reporters` array in your `karma.conf.js`.","symbol":"reporters configuration","correct":"reporters: ['progress', 'cucumber']"},{"note":"Configuration options like `out` (output file path) and `prefix` (to filter tests) are set under the `cucumberReporter` property in `karma.conf.js`.","symbol":"cucumberReporter options","correct":"cucumberReporter: { out: './report.json', prefix: 'MyApp' }"}],"quickstart":{"code":"npm install -D karma karma-jasmine karma-chrome-launcher karma-cucumber-reporter\n\n// karma.conf.js\nmodule.exports = function(config) {\n  config.set({\n    frameworks: ['jasmine'],\n    files: [\n      'test/**/*.spec.js'\n    ],\n    reporters: ['progress', 'cucumber'],\n    plugins: [\n      'karma-jasmine',\n      'karma-chrome-launcher',\n      require('karma-cucumber-reporter')\n    ],\n    browsers: ['ChromeHeadless'],\n    singleRun: true,\n    autoWatch: false,\n    cucumberReporter: {\n      out: './cucumber-report.json', // Output file for the Cucumber JSON report\n      prefix: 'FeaturePrefix'       // Prefix to identify features for reporting\n    }\n  });\n};\n\n// test/example.spec.js\ndescribe('FeaturePrefix MyApplication Feature', function () {\n  describe('Scenario: As a user, I can log in successfully', function () {\n    it('Given I am on the login page', function () {\n      expect(true).toBe(true); // Placeholder for actual test logic\n    });\n\n    it('When I enter valid credentials', function () {\n      expect('username').toEqual('username');\n      expect('password').toEqual('password');\n    });\n\n    it('Then I should be redirected to the dashboard', function () {\n      expect(1 + 1).toBe(2);\n    });\n  });\n\n  describe('Scenario: As an admin, I can manage users', function () {\n    it('Given I am logged in as an admin', function () {\n      expect(true).toBe(true);\n    });\n    it('When I navigate to the user management section', function () {\n      expect(true).toBe(true);\n    });\n    it('Then I should see a list of users', function () {\n      expect(false).not.toBe(true);\n    });\n  });\n});","lang":"javascript","description":"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."},"warnings":[{"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.","message":"Tests 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure `cucumberReporter.prefix` in `karma.conf.js` is identical to the prefix used in your feature `describe` blocks in test files.","message":"The `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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always include one or more `describe('Scenario Name', ...)` blocks within each `describe('Prefix Feature Name', ...)` block.","message":"Each 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure `reporters: ['progress', 'cucumber']` and `plugins: [..., require('karma-cucumber-reporter')]` are correctly configured in `karma.conf.js`.","cause":"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.","error":"Error: No reporters found: cucumber"},{"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.","cause":"The `out` option for `cucumberReporter` is not set, or tests do not match the required `prefix` or structural requirements for features and scenarios.","error":"Cucumber report file is empty or missing after test run"},{"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`.","cause":"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.","error":"Tests run, but do not appear in the generated Cucumber report, or the report is malformed."}],"ecosystem":"npm"}