{"library":"mutation-testing-metrics","title":"Mutation Testing Metrics Utilities","description":"The `mutation-testing-metrics` package provides a set of utility functions designed to calculate and aggregate mutation testing metrics from mutation test reports. Currently at version 3.7.3, it is an actively maintained component within the Stryker Mutator ecosystem, with a release cadence that appears to be every few months, addressing bug fixes and minor feature enhancements. Its key differentiators include the ability to programmatically process `MutationTestResult` objects, perform detailed metric calculations, and aggregate multiple module-level reports into a single, consolidated view. This enables developers and CI/CD pipelines to deeply analyze the effectiveness of their test suites, going beyond simple code coverage by evaluating how well tests detect intentionally introduced faults (mutants). It is built with TypeScript, providing strong type guarantees for its API.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mutation-testing-metrics"],"cli":null},"imports":["import { calculateMutationTestMetrics } from 'mutation-testing-metrics';","import type { MetricsResult } from 'mutation-testing-metrics';","import { aggregateResultsByModule } from 'mutation-testing-metrics';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { MetricsResult, calculateMutationTestMetrics } from 'mutation-testing-metrics';\nimport type { MutationTestResult } from 'mutation-testing-report-schema';\n\n// In a real scenario, mutationTestReport would be loaded from a file or generated\nconst mutationTestReport: MutationTestResult = {\n  $schema: 'https://raw.githubusercontent.com/stryker-mutator/mutation-testing-elements/master/packages/report-schema/src/mutation-testing-report-schema.json',\n  schemaVersion: '1.4',\n  thresholds: {\n    high: 80,\n    low: 60\n  },\n  files: {\n    'src/calculator.js': {\n      language: 'javascript',\n      mutants: [\n        {\n          id: '1',\n          mutatorName: 'BinaryExpression',\n          replacement: 'a - b',\n          location: { start: { line: 1, column: 15 }, end: { line: 1, column: 20 } },\n          status: 'Survived'\n        },\n        {\n          id: '2',\n          mutatorName: 'BinaryExpression',\n          replacement: 'a / b',\n          location: { start: { line: 1, column: 15 }, end: { line: 1, column: 20 } },\n          status: 'Killed'\n        }\n      ],\n      source: 'const add = (a, b) => a + b;'\n    },\n    'src/subtract.js': {\n      language: 'javascript',\n      mutants: [\n        {\n          id: '3',\n          mutatorName: 'BinaryExpression',\n          replacement: 'a + b',\n          location: { start: { line: 1, column: 18 }, end: { line: 1, column: 23 } },\n          status: 'NoCoverage'\n        }\n      ],\n      source: 'const subtract = (a, b) => a - b;'\n    }\n  }\n};\n\nconst result: MetricsResult = calculateMutationTestMetrics(mutationTestReport);\n\nconsole.log('--- Mutation Test Metrics ---');\nconsole.log('Total mutants:', result.metrics.totalMutants);\nconsole.log('Killed mutants:', result.metrics.killed);\nconsole.log('Survived mutants:', result.metrics.survived);\nconsole.log('No Coverage mutants:', result.metrics.noCoverage);\nconsole.log('Mutation score:', result.metrics.mutationScore.toFixed(2) + '%');","lang":"typescript","description":"This example demonstrates how to use `calculateMutationTestMetrics` to process a `MutationTestResult` object and output key metrics like total mutants, killed, survived, and the overall mutation score.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}