Root — stryker.conf.json

Module: root-stryker-conf-json Cohesion: 0.80 Members: 0

Root — stryker.conf.json

This document details the stryker.conf.json file, which serves as the primary configuration for Stryker Mutator within this project.

stryker.conf.json: Stryker Mutator Configuration

The stryker.conf.json file is a crucial part of our quality assurance pipeline, defining how mutation testing is performed on the codebase. It dictates which files are mutated, how tests are run against those mutations, and how results are reported.

Purpose

The main purpose of stryker.conf.json is to configure the Stryker Mutator tool. Stryker introduces small, controlled changes (mutations) to the source code and then runs the project's tests against these mutated versions. If a test suite passes against a mutated version of the code, it indicates that the tests are not robust enough to "kill" that mutation, suggesting a potential gap in test coverage or logic.

This configuration file ensures:

How it Works

When the stryker CLI command is executed (e.g., stryker run), it reads this stryker.conf.json file to determine its operational parameters. It then:

  1. Identifies the files to mutate based on the mutate patterns.
  2. Sets up the specified testRunner (Jest) using the provided jest.configFile.
  3. Applies various performance and reporting settings.
  4. Executes the mutation testing process, generating reports as configured.

This file is static and is consumed directly by the Stryker application; it does not contain executable code or define any internal execution flows within our project's runtime.

Key Configuration Sections

The stryker.conf.json is structured into several logical sections, each controlling a specific aspect of the mutation testing process.

1. General Settings

These settings define the overall environment and basic behavior of Stryker.

    "reporters": ["html", "clear-text", "progress", "dashboard"]

2. Test Runner Integration

This section configures how Stryker interacts with our testing framework.

    "jest": {
      "projectType": "custom",
      "configFile": "jest.config.js",
      "enableFindRelatedTests": true
    }
    "coverageAnalysis": "perTest"

perTest means Stryker will analyze which tests cover which parts of the code, allowing it to run only relevant tests for each mutation, further optimizing performance.

3. Mutation Scope

These patterns define which files are considered for mutation and which are explicitly ignored.

    "ignorePatterns": [
      "node_modules",
      "dist",
      "coverage",
      "tests"
    ]
    "mutator": {
      "excludedMutations": [
        "StringLiteral",
        "ObjectLiteral"
      ]
    }

Excluding StringLiteral and ObjectLiteral mutations can reduce noise from mutations that are often trivial or lead to non-deterministic test failures, allowing focus on more critical logic mutations.

4. Performance & Resources

Settings to control the execution speed and resource consumption of Stryker.

    "timeoutMS": 60000 // 60 seconds
    "timeoutFactor": 2
    "concurrency": 4

5. Reporting & Thresholds

Configuration for how mutation results are presented and evaluated.

    "htmlReporter": {
      "fileName": "reports/mutation/mutation.html"
    }

This specifies the output path for the generated HTML report.

    "dashboard": {
      "project": "github.com/phuetz/code-buddy",
      "version": "main",
      "module": "code-buddy"
    }

These parameters identify the project, branch (version), and specific module for dashboard reporting, enabling historical tracking and comparison of mutation scores.

    "thresholds": {
      "high": 80,
      "low": 60,
      "break": 50
    }

6. Type Checking & Incremental Runs

Advanced settings for type checking and optimizing subsequent runs.

    "disableTypeChecks": "{src/**/*.ts,src/**/*.tsx}"

How it Connects to the Project

stryker.conf.json is integral to our project's quality assurance strategy:

Contributing and Modifying

When modifying stryker.conf.json, consider the following: