Mutation Testing Analysis Utilities

Helper scripts for analyzing Stryker mutation testing reports.

analyze-mutations.js

Efficiently extracts and analyzes data from large mutation JSON reports.

Usage

node analyze-mutations.js <command> <file> [options]

Commands

summary <file>

Get overall mutation metrics for a file.

node analyze-mutations.js summary server/services/googleSheetsApi.js

Output:

{
  "total": 162,
  "killed": 48,
  "survived": 20,
  "noCoverage": 88,
  "timeout": 2,
  "score": 29.63
}

survived <file>

List all survived mutants with line numbers.

node analyze-mutations.js survived server/routes/projects.js

Output:

[
  {
    "id": "346",
    "line": 75,
    "column": 10,
    "mutatorName": "EqualityOperator",
    "replacement": "col <= dateRow.length"
  },
  ...
]

by-type <file>

Group survived mutants by mutator type.

node analyze-mutations.js by-type server/utils/dateUtils.js

Output:

{
  "EqualityOperator": [
    { "id": "346", "line": 75, "replacement": "col <= dateRow.length" }
  ],
  "ConditionalExpression": [
    { "id": "352", "line": 78, "replacement": "false" }
  ],
  ...
}

by-line <file> <line>

Get all mutants at a specific line number.

node analyze-mutations.js by-line server/services/cacheService.js 45

Output:

[
  {
    "id": "123",
    "status": "Killed",
    "mutatorName": "ConditionalExpression",
    "replacement": "true",
    "line": 45,
    "column": 10
  }
]

high-priority <file>

Categorize survived mutants by priority (high/medium/low).

node analyze-mutations.js high-priority server/services/googleSheetsApi.js

Output:

{
  "high": [
    {
      "mutatorName": "EqualityOperator",
      "count": 3,
      "mutants": [...]
    }
  ],
  "medium": [...],
  "low": [...]
}

Priority Levels

Environment Variables

MUTATION_REPORT=custom/path/report.json node analyze-mutations.js summary myfile.js

Using as a Module

import { getSummary, groupByType, loadReport, findFileData } from './analyze-mutations.js';

const report = loadReport('reports/mutation/mutation.json');
const { data } = findFileData(report, 'server/services/myService.js');
const summary = getSummary(data);
const grouped = groupByType(data);

Benefits

Examples in the Wild

Used by the /improve-test-quality skill to:

  1. Baseline analysis (get current mutation score)
  2. Identify survived mutants to target
  3. Categorize by priority for systematic improvement
  4. Verify improvements after re-running tests