{"id":13032,"library":"cucumber-json-merge","title":"Cucumber JSON Report Merge Utility","description":"cucumber-json-merge is a utility designed for combining multiple Cucumber JSON test reports into a single, unified report. It functions as both a Node.js command-line interface (CLI) and an importable JavaScript library, primarily supporting CommonJS modules. The current stable version is 0.0.8, with recent updates indicating active maintenance, though without a strict release cadence. Its core functionality enables users to aggregate test results, which is particularly useful in CI/CD environments where tests might run in parallel or across different suites, producing fragmented reports. The package differentiates itself by offering both a direct CLI for quick usage and an API for programmatic integration into larger Node.js applications, building upon similar concepts found in `junit-merge`.","status":"active","version":"0.0.8","language":"javascript","source_language":"en","source_url":"https://github.com/bitcoder/cucumber-json-merge","tags":["javascript","cucumber","reports"],"install":[{"cmd":"npm install cucumber-json-merge","lang":"bash","label":"npm"},{"cmd":"yarn add cucumber-json-merge","lang":"bash","label":"yarn"},{"cmd":"pnpm add cucumber-json-merge","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package is primarily designed for CommonJS module systems. Direct ESM 'import' syntax may not work out-of-the-box and could require a transpilation step or specific Node.js loader configuration.","wrong":"import cucumberJsonMerge from 'cucumber-json-merge';","symbol":"cucumberJsonMerge","correct":"const cucumberJsonMerge = require('cucumber-json-merge');"},{"note":"The `mergeFiles` function is exported as a property of the main CommonJS module. While destructuring is common in CJS, direct ESM named imports are not supported without specific configurations.","wrong":"import { mergeFiles } from 'cucumber-json-merge';","symbol":"mergeFiles","correct":"const { mergeFiles } = require('cucumber-json-merge');"},{"note":"The `listJsonFiles` function is part of the main CommonJS module export. Attempting to use it with ESM 'import' syntax will likely result in an error.","wrong":"import { listJsonFiles } from 'cucumber-json-merge';","symbol":"listJsonFiles","correct":"const { listJsonFiles } = require('cucumber-json-merge');"}],"quickstart":{"code":"const cukemerge = require('cucumber-json-merge');\nconst fs = require('fs');\nconst path = require('path');\n\n// Create a temporary directory and dummy JSON files for demonstration\nconst tempDir = './temp-cucumber-results';\nfs.mkdirSync(tempDir, { recursive: true });\n\nconst report1 = [\n  {\n    \"uri\": \"features/feature1.feature\",\n    \"elements\": [{\"name\": \"Scenario A\", \"steps\": [], \"id\": \"scenario-a\"}]\n  }\n];\nconst report2 = [\n  {\n    \"uri\": \"features/feature2.feature\",\n    \"elements\": [{\"name\": \"Scenario B\", \"steps\": [], \"id\": \"scenario-b\"}]\n  }\n];\n\nfs.writeFileSync(path.join(tempDir, 'report1.json'), JSON.stringify(report1, null, 2));\nfs.writeFileSync(path.join(tempDir, 'report2.json'), JSON.stringify(report2, null, 2));\n\nconsole.log('Created dummy reports in:', tempDir);\n\n// List JSON files in the directory (non-recursive)\nconst files = cukemerge.listJsonFiles(tempDir, false);\nconsole.log('Found files to merge:', files);\n\n// Merge the found files\nconst mergedResults = cukemerge.mergeFiles(files);\nconsole.log('--- Merged Cucumber JSON Report ---');\nconsole.log(JSON.stringify(mergedResults, null, 2));\nconsole.log('-----------------------------------');\n\n// Clean up temporary files and directory\nfs.unlinkSync(path.join(tempDir, 'report1.json'));\nfs.unlinkSync(path.join(tempDir, 'report2.json'));\nfs.rmdirSync(tempDir);\nconsole.log('Cleaned up temporary directory:', tempDir);\n","lang":"javascript","description":"This quickstart demonstrates how to use `cucumber-json-merge` as a library to list and merge Cucumber JSON report files programmatically. It sets up dummy report files in a temporary directory, performs the merge operation, and then cleans up."},"warnings":[{"fix":"Always review the changelog before upgrading to new versions and pin exact dependency versions in `package.json` to prevent unexpected behavior.","message":"The package is currently at version 0.0.8. While actively maintained, pre-1.0 versions may introduce breaking changes in minor or patch releases, though none are explicitly documented yet.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Ensure your project uses CommonJS for `cucumber-json-merge` imports, or consider a transpilation step if integrating into an ESM-only codebase.","message":"The package is primarily built and documented for CommonJS (CJS) environments using `require()`. Attempting to use `import` statements for ESM modules may lead to errors or require additional configuration (e.g., `\"type\": \"module\"` in `package.json` and explicit file extensions) which is not officially supported by the package.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Upgrade to the latest version of `cucumber-json-merge` (0.0.8 or newer) to ensure patched dependencies are used. Regularly run `npm audit`.","message":"A dependency (`mkdirp`) was updated due to a Snyk security vulnerability. While the fix is integrated, users should regularly run security audits (e.g., `npm audit`) on their projects to identify and address any transitive dependency vulnerabilities.","severity":"gotcha","affected_versions":"<0.0.8"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Run `npm install cucumber-json-merge` in your project directory, or `npm install -g cucumber-json-merge` if using the CLI globally.","cause":"The package has not been installed or is not accessible in the current project's `node_modules`.","error":"Error: Cannot find module 'cucumber-json-merge'"},{"fix":"Install the package globally using `npm install -g cucumber-json-merge` or ensure your shell's PATH includes the global npm binary directory.","cause":"The CLI tool is not in your system's PATH. This typically happens if it was not installed globally or the global `node_modules` bin directory is not in PATH.","error":"cucumber-json-merge: command not found"},{"fix":"Verify that the input JSON files are valid Cucumber reports and that the paths provided to the CLI (`-d` or direct file arguments) or library (`listJsonFiles`) are correct and accessible.","cause":"The input directory or specified files did not contain valid Cucumber JSON reports, or the file paths were incorrect.","error":"Merged report is empty or incomplete"},{"fix":"Use the `-o <filename>` option to specify an output file, e.g., `cucumber-json-merge report1.json report2.json -o merged-results.json`.","cause":"When using the CLI, the `--out` or `-o` option was not specified, and the command might have only printed to stdout.","error":"No output file created (when using CLI)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"cucumber-json-merge"}