CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-stryker-mutator--jest-runner

A plugin to use the jest test runner and framework in Stryker, the JavaScript mutation testing framework

Pending
Overview
Eval results
Files

plugin-integration.mddocs/

Plugin Integration

Core plugin registration and validation schema for Stryker integration. Provides the main entry point for using Jest as a test runner in Stryker mutation testing.

Capabilities

Stryker Plugin Declaration

The main plugin export that registers Jest as a test runner with Stryker's plugin system.

/**
 * Array of Stryker plugin declarations for Jest test runner
 * Contains the Jest test runner factory plugin registration
 */
export const strykerPlugins: Array<PluginDeclaration>;

Usage Example:

import { strykerPlugins } from "@stryker-mutator/jest-runner";

// Plugins are automatically registered when the package is loaded
// Used internally by Stryker to discover and load the Jest test runner
console.log(strykerPlugins); // [{ kind: 'TestRunner', name: 'jest', factory: ... }]

Validation Schema

JSON schema for validating Jest runner configuration options.

/**
 * Validation schema for Jest runner options
 * Loaded from schema/jest-runner-options.json
 */
export const strykerValidationSchema: JestRunnerOptionsSchema;

Usage Example:

import { strykerValidationSchema } from "@stryker-mutator/jest-runner";

// Schema is used internally by Stryker for configuration validation
// Contains validation rules for jest configuration options
console.log(strykerValidationSchema.properties.jest);

Types

Plugin Declaration Types

interface PluginDeclaration {
  kind: PluginKind.TestRunner;
  name: 'jest';
  factory: typeof jestTestRunnerFactory;
}

enum PluginKind {
  TestRunner = 'TestRunner',
  // ... other plugin types
}

Schema Types

interface JestRunnerOptionsSchema {
  $schema: string;
  type: 'object';
  title: 'JestRunnerOptions';
  additionalItems: boolean;
  properties: {
    jest: JestOptionsSchema;
  };
  definitions: {
    jestProjectType: JestProjectTypeSchema;
  };
}

interface JestOptionsSchema {
  title: 'JestOptions';
  description: string;
  type: 'object';
  default: {};
  properties: {
    projectType: { $ref: '#/definitions/jestProjectType' };
    configFile: { description: string; type: 'string' };
    config: { description: string; type: 'object' };
    enableFindRelatedTests: { description: string; type: 'boolean'; default: true };
  };
  additionalProperties: boolean;
}

Environment Setup

The plugin automatically sets up the testing environment:

// Automatically set when the package is loaded
process.env.BABEL_ENV = 'test';

This ensures that Babel transformations are applied correctly for Jest testing within the Stryker environment.

Integration with Stryker Core

The plugin integrates with Stryker through the dependency injection system:

  • Plugin Discovery: Stryker discovers Jest runner through strykerPlugins export
  • Factory Creation: Uses jestTestRunnerFactory to create test runner instances
  • Validation: Applies strykerValidationSchema to validate Jest configuration
  • Lifecycle Management: Handles initialization, execution, and cleanup through the TestRunner interface

Install with Tessl CLI

npx tessl i tessl/npm-stryker-mutator--jest-runner

docs

configuration.md

environment-integration.md

index.md

plugin-integration.md

test-runner.md

utilities.md

tile.json