or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

circus.mdconfig.mdglobal.mdindex.mdtest-result.mdtransform.md
tile.json

tessl/npm-jest--types

Comprehensive TypeScript type definitions for the Jest testing framework ecosystem providing shared types for configuration, test results, transforms, and global utilities.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@jest/types@30.0.x

To install, run

npx @tessl/cli install tessl/npm-jest--types@30.0.0

index.mddocs/

Jest Types

Jest Types provides comprehensive TypeScript type definitions for the Jest testing framework ecosystem. It contains shared types used across Jest's internal packages and offers public interfaces for Jest configuration, test results, transforms, circus (Jest's test runner), and global utilities.

Package Information

  • Package Name: @jest/types
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @jest/types

Core Imports

import type { Circus, Config, Global, TestResult, TransformTypes } from "@jest/types";

For specific namespace imports:

import type { Config } from "@jest/types";
import type { Global } from "@jest/types";

Basic Usage

import type { Config, Global } from "@jest/types";

// Define Jest configuration with proper typing
const config: Config.InitialOptions = {
  testEnvironment: "node",
  collectCoverage: true,
  coverageDirectory: "coverage",
  testMatch: ["**/__tests__/**/*.ts"],
};

// Type test functions
const testFn: Global.TestFn = async () => {
  // Test implementation
};

// Type hooks
const hookFn: Global.HookFn = async () => {
  // Setup or teardown logic
};

Architecture

Jest Types is organized into five main namespace modules:

  • Global Module: Types for Jest's global test framework functions, hooks, and interfaces
  • Config Module: Comprehensive configuration types for Jest setup and options
  • Circus Module: Types for Jest's Circus test runner including events and state management
  • TestResult Module: Types for test execution results and assertions
  • Transform Module: Types for Jest's code transformation system

Each module provides complete type coverage for its respective domain, enabling type-safe Jest usage and plugin development.

Capabilities

Global Test Framework Types

Core types for Jest's global test functions, hooks, and test organization. Essential for typing test files and custom test utilities.

interface TestFrameworkGlobals {
  it: ItConcurrent;
  test: ItConcurrent;
  fit: ItBase & { concurrent?: ItConcurrentBase };
  xit: ItBase;
  xtest: ItBase;
  describe: Describe;
  xdescribe: DescribeBase;
  fdescribe: DescribeBase;
  beforeAll: HookBase;
  beforeEach: HookBase;
  afterEach: HookBase;
  afterAll: HookBase;
}

type TestFn = PromiseReturningTestFn | GeneratorReturningTestFn | DoneTakingTestFn;
type HookFn = TestFn;
type DoneFn = (reason?: string | Error) => void;

Global Types

Jest Configuration Types

Complete configuration types for Jest setup including fake timers, coverage, module resolution, and test execution options.

interface InitialOptions {
  // Core configuration
  testEnvironment?: string;
  testMatch?: Array<string>;
  testRegex?: string | Array<string>;
  collectCoverage?: boolean;
  coverageDirectory?: string;
  
  // Fake timers configuration
  fakeTimers?: FakeTimers;
  
  // Module configuration
  moduleNameMapper?: Record<string, string | Array<string>>;
  moduleFileExtensions?: Array<string>;
  
  // Transform configuration
  transform?: Record<string, string | [string, Record<string, unknown>]>;
}

interface GlobalConfig {
  bail: number;
  collectCoverage: boolean;
  coverageDirectory: string;
  maxWorkers: number;
  testPathPatterns: TestPathPatterns;
  // ... extensive configuration options
}

Configuration Types

Circus Test Runner Types

Types for Jest's Circus test runner including event handling, test execution state, and test organization structures.

interface State {
  currentDescribeBlock: DescribeBlock;
  currentlyRunningTest?: TestEntry | null;
  hasFocusedTests: boolean;
  rootDescribeBlock: DescribeBlock;
  testTimeout: number;
  unhandledErrors: Array<Exception>;
}

interface TestEntry {
  type: 'test';
  fn: TestFn;
  name: TestName;
  parent: DescribeBlock;
  mode: TestMode;
  concurrent: boolean;
  timeout?: number;
  status?: TestStatus | null;
}

type Event = SyncEvent | AsyncEvent;

Circus Types

Test Result Types

Types for test execution results, assertions, and error handling to support test reporting and analysis.

interface AssertionResult {
  ancestorTitles: Array<string>;
  duration?: number | null;
  failing?: boolean;
  failureDetails: Array<unknown>;
  failureMessages: Array<string>;
  fullName: string;
  numPassingAsserts: number;
  status: Status;
  title: string;
}

interface SerializableError {
  code?: unknown;
  message: string;
  stack: string | null | undefined;
  type?: string;
}

Test Result Types

Transform Types

Types for Jest's code transformation system enabling custom transformers and build tool integration.

interface TransformResult {
  code: string;
  originalCode: string;
  sourceMapPath: string | null;
}

Transform Types