{"id":13382,"library":"jest-teamcity-reporter","title":"Jest TeamCity Reporter","description":"Jest TeamCity Reporter is a utility package designed to integrate JavaScript Jest test results directly into TeamCity CI builds. Currently at version 0.9.0, it processes Jest's test output and formats it into TeamCity service messages, enabling TeamCity to display test statistics, failures, and test coverage information directly within its UI. Releases appear to be driven by feature additions (like coverage reporting introduced in 0.8.0, and TC10 support in 0.9.0) and bug fixes, with a moderate and stable cadence rather than rapid-fire development. Key differentiators include its seamless integration with TeamCity's native reporting capabilities, providing a rich testing experience directly within the CI dashboard. Its automatic activation based on the `TEAMCITY_VERSION` environment variable is also a significant feature, ensuring it only runs within a TeamCity environment, preventing local execution interference or requiring manual toggles. This makes it a highly specialized and focused tool, ideal for development teams leveraging Jest for their JavaScript testing and TeamCity for their continuous integration pipelines, streamlining the visibility of test outcomes and code quality metrics.","status":"active","version":"0.9.0","language":"javascript","source_language":"en","source_url":"git://github.com/winterbe/jest-teamcity-reporter","tags":["javascript","jest","unittest","test","teamcity","reporter","integration","ci"],"install":[{"cmd":"npm install jest-teamcity-reporter","lang":"bash","label":"npm"},{"cmd":"yarn add jest-teamcity-reporter","lang":"bash","label":"yarn"},{"cmd":"pnpm add jest-teamcity-reporter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package acts as a Jest `testResultsProcessor`, requiring Jest to be installed as a peer or dev dependency for its functionality.","package":"jest","optional":false}],"imports":[{"note":"The primary way to enable this reporter is by configuring it as a `testResultsProcessor` string path in your Jest configuration (either `package.json` or `jest.config.js`). It automatically processes test results when enabled this way.","wrong":"import { reporter } from 'jest-teamcity-reporter';","symbol":"jest-teamcity-reporter","correct":"// In your package.json:\n\"jest\": {\n  \"testResultsProcessor\": \"jest-teamcity-reporter\"\n}"},{"note":"For advanced use cases, such as chaining with other custom test result processors or programmatic invocation, you can directly import the default exported function. This function expects Jest's `AggregatedResult` object as an argument.","wrong":"import { TeamcityReporter } from 'jest-teamcity-reporter';","symbol":"Default Export Function","correct":"const processResults = require('jest-teamcity-reporter');\n// or for ESM:\nimport processResults from 'jest-teamcity-reporter';"},{"note":"While not a code import, the presence of the `TEAMCITY_VERSION` environment variable is crucial for the reporter's activation. It will be silently disabled if this variable is not set, which is a frequent source of user confusion. Set it in your CI environment or locally for testing.","wrong":"jest --teamcity-version 10.0","symbol":"TEAMCITY_VERSION (Environment Variable)","correct":"export TEAMCITY_VERSION=\"your_version\""}],"quickstart":{"code":"{\n  \"name\": \"my-jest-project\",\n  \"version\": \"1.0.0\",\n  \"scripts\": {\n    \"test\": \"jest --coverage\" // Added --coverage to demonstrate latest features\n  },\n  \"devDependencies\": {\n    \"jest\": \"^29.0.0\",\n    \"jest-teamcity-reporter\": \"0.9.0\"\n  },\n  \"jest\": {\n    \"testResultsProcessor\": \"jest-teamcity-reporter\"\n  }\n}\n\n// example.test.js\ndescribe('Arithmetic Operations', () => {\n  test('should correctly add two numbers', () => {\n    expect(1 + 2).toBe(3);\n  });\n\n  test('should handle multiplication', () => {\n    expect(2 * 3).toBe(6);\n  });\n\n  test('should report a failure when expected', () => {\n    // This test is intentionally designed to fail to show failure reporting in TeamCity\n    // expect(5).toBe(10);\n    expect(5).not.toBe(10); // Changed to pass for a successful quickstart run demonstration\n  });\n\n  // function for coverage demonstration\n  function coveredFunction(a, b) {\n    if (a > b) return a - b;\n    return a + b;\n  }\n  test('should cover a function', () => {\n    expect(coveredFunction(5, 3)).toBe(2);\n    expect(coveredFunction(2, 4)).toBe(6);\n  });\n});\n\n// To run locally and simulate the TeamCity environment:\n// 1. Install dependencies: npm install\n// 2. Set the environment variable: export TEAMCITY_VERSION=\"10.0\"\n// 3. Run tests: npm test\n// 4. To disable for local runs: unset TEAMCITY_VERSION","lang":"javascript","description":"This quickstart demonstrates how to install and configure `jest-teamcity-reporter` in your `package.json` for a Jest project. It includes a basic test suite and explains how to run tests, simulating the necessary TeamCity environment variable for reporter activation, and shows an example with coverage."},"warnings":[{"fix":"Remove the `--teamcity` flag from your Jest command. Configure the reporter by adding `\"testResultsProcessor\": \"jest-teamcity-reporter\"` to your Jest configuration within `package.json` or `jest.config.js`.","message":"The command-line interface (CLI) option `--teamcity` for activating the reporter was removed in version 0.5.0. Jest no longer supports custom CLI options for reporters.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Ensure `TEAMCITY_VERSION` is set in your TeamCity build configuration. For local testing, temporarily set the variable (e.g., `export TEAMCITY_VERSION=\"10.0\"` in your shell) before running Jest.","message":"The reporter is only active and outputs TeamCity service messages when the `TEAMCITY_VERSION` environment variable is present. It will be silently disabled if this variable is not set.","severity":"gotcha","affected_versions":">=0.5.0"},{"fix":"Upgrade to `jest-teamcity-reporter` version 0.3.0 or higher to ensure compatibility with Jest 18+. Always verify reporter compatibility with your specific Jest version.","message":"Versions of `jest-teamcity-reporter` prior to 0.3.0 did not officially support Jest versions 18 and above, potentially leading to incorrect reporting or errors.","severity":"breaking","affected_versions":"<0.3.0"},{"fix":"To get Jest test coverage reported in TeamCity, upgrade to `jest-teamcity-reporter` version 0.8.0 or newer. For full TC10 coverage features, use version 0.9.0 or later.","message":"Coverage statistics reporting to TeamCity was introduced in version 0.8.0 and further refined for TeamCity 10 (TC10) in version 0.9.0. Older versions will not report coverage.","severity":"gotcha","affected_versions":"<0.8.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Verify that `TEAMCITY_VERSION` is defined in your TeamCity build configuration. Confirm that your `package.json` (or `jest.config.js`) contains `\"jest\": { \"testResultsProcessor\": \"jest-teamcity-reporter\" }`.","cause":"The `TEAMCITY_VERSION` environment variable is not set in the build environment, or the `testResultsProcessor` is incorrectly configured.","error":"Jest test results are not showing up in TeamCity's 'Tests' tab, or the reporter appears inactive."},{"fix":"Remove the `--teamcity` flag from your Jest command. Configure the reporter solely via the `testResultsProcessor` property in your Jest configuration.","cause":"Attempting to use the deprecated `--teamcity` CLI option, which was removed in `jest-teamcity-reporter` version 0.5.0 as Jest no longer supports custom reporter options via CLI.","error":"Error: Unknown option '--teamcity' when running Jest."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}