{"id":14641,"library":"jest-json-reporter","title":"Jest JSON Reporter","description":"jest-json-reporter is a utility package for Jest that processes test results and outputs them to a specified JSON file. It adheres to the JSON format defined by Jest's own documentation, making it suitable for integration into Continuous Integration (CI) pipelines, custom reporting dashboards, or any system that consumes structured test results. The package is currently at version 1.2.2 and generally operates as a 'set-and-forget' utility, meaning its release cadence is typically slow, focused on stability and compatibility with new Jest versions rather than frequent feature additions. Its key differentiator is its straightforward, minimal configuration for generating a standard JSON report, which is often preferred over more complex or opinionated reporting solutions when raw data is needed for further processing.","status":"active","version":"1.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/Vall3y/jest-json-reporter","tags":["javascript","test","jest","reporter"],"install":[{"cmd":"npm install jest-json-reporter","lang":"bash","label":"npm"},{"cmd":"yarn add jest-json-reporter","lang":"bash","label":"yarn"},{"cmd":"pnpm add jest-json-reporter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a Jest test results processor and requires Jest to be installed as a peer dependency for its functionality.","package":"jest","optional":false}],"imports":[{"note":"jest-json-reporter is not directly imported into application code. Instead, it is configured within Jest's `package.json` or `jest.config.js` via a string path, which Jest then uses to load the CommonJS module at runtime. The 'symbol' refers to the module path itself as Jest's configuration entry point. Direct `import` or `require` in user code is not the intended usage.","wrong":"import reporter from 'jest-json-reporter';","symbol":"JestJSONReporterPath","correct":"\"testResultsProcessor\": \"./node_modules/jest-json-reporter\""}],"quickstart":{"code":"npm install --save-dev jest jest-json-reporter\n\n// package.json\n// Add the following configuration to your package.json:\n// {\n//   \"name\": \"my-project\",\n//   \"version\": \"1.0.0\",\n//   \"devDependencies\": {\n//     \"jest\": \"^29.0.0\",\n//     \"jest-json-reporter\": \"^1.0.0\"\n//   },\n//   \"jest\": {\n//     \"testResultsProcessor\": \"./node_modules/jest-json-reporter\",\n//     \"testEnvironment\": \"node\"\n//   },\n//   \"jestJsonReporter\": {\n//     \"outputFile\": \"jest-test-results.json\"\n//   }\n// }\n\n// __tests__/example.test.ts\n// Create a simple test file, e.g., '__tests__/example.test.ts':\ndescribe('Basic math operations', () => {\n  test('adds 1 + 2 to equal 3', () => {\n    expect(1 + 2).toBe(3);\n  });\n\n  test('multiplies 2 * 3 to equal 6', () => {\n    expect(2 * 3).toBe(6);\n  });\n});\n\n// Run Jest from your terminal\nnpx jest\n\n// Verify the JSON output file\n// cat jest-test-results.json\n","lang":"typescript","description":"Demonstrates how to install jest-json-reporter, configure it in package.json, run Jest with a basic test, and verify the generated JSON output file."},"warnings":[{"fix":"Consult the `jest-json-reporter` GitHub repository for specific version compatibility notes or open an issue if an incompatibility arises. Pin Jest versions if necessary.","message":"Major Jest version updates (e.g., Jest v27, v28, v29+) can sometimes introduce changes to the reporter API or how modules are resolved (e.g., ESM vs. CJS). While generally stable, ensure compatibility by testing against new Jest versions before upgrading in production.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always use a path relative to your project's root (e.g., `./node_modules/jest-json-reporter`) or an absolute path. Double-check for typos.","message":"The `testResultsProcessor` path in `package.json` or `jest.config.js` must be correct and resolvable from the project root. Incorrect relative paths or typos will lead to Jest failing to load the reporter.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Configure a unique `outputFile` name and path, especially in CI environments where multiple jobs might run in parallel or where results need to be archived distinctly. For example, `outputFile: 'reports/jest-results-${process.env.CI_JOB_ID || Date.now()}.json'`.","message":"The `outputFile` configuration determines where the JSON results are written. If not configured, it defaults to `test-results.json` in the project root. Using a non-unique or shared `outputFile` path across different test runs or CI stages can lead to files being overwritten.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Verify that `jest-json-reporter` is installed (check `node_modules` and `package.json`). Ensure the path in `testResultsProcessor` is exactly `./node_modules/jest-json-reporter`.","cause":"Jest could not resolve the specified path for the test results processor, likely due to a typo, incorrect path, or the package not being installed.","error":"Cannot find module './node_modules/jest-json-reporter' from 'package.json'"},{"fix":"Ensure your Jest configuration (`testMatch`, `testRegex`) correctly identifies your test files. The `jest-json-reporter` will only output results if Jest actually runs tests.","cause":"This error itself isn't directly from `jest-json-reporter`, but if Jest isn't configured correctly to find tests, the reporter won't have any results to process, leading to confusion about its operation.","error":"Jest: No tests found, exiting with error code 1"}],"ecosystem":"npm"}