or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

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

config.mddocs/

0

# Jest Configuration Types

1

2

Complete configuration types for Jest setup including fake timers, coverage, module resolution, and test execution options. Essential for creating type-safe Jest configurations and custom Jest tooling.

3

4

## Capabilities

5

6

### External Type Dependencies

7

8

Types from external packages used in Jest configuration.

9

10

```typescript { .api }

11

/**

12

* Report options from istanbul-reports package

13

*/

14

type ReportOptions = Record<string, any>;

15

16

/**

17

* Foreground color type from chalk package

18

*/

19

type ForegroundColor = string;

20

21

/**

22

* Test path patterns from @jest/pattern package

23

*/

24

type TestPathPatterns = Array<string>;

25

26

/**

27

* Snapshot format configuration from @jest/schemas package

28

*/

29

type SnapshotFormat = Record<string, any>;

30

31

/**

32

* Arguments type from yargs package

33

*/

34

type Arguments<T> = T & {

35

_: Array<string | number>;

36

$0: string;

37

};

38

```

39

40

### Core Configuration Interface

41

42

Main Jest configuration interface with all available options.

43

44

```typescript { .api }

45

/**

46

* Initial Jest configuration options (re-exported from @jest/schemas)

47

*/

48

interface InitialOptions {

49

// Test execution

50

testEnvironment?: string;

51

testMatch?: Array<string>;

52

testRegex?: string | Array<string>;

53

testPathIgnorePatterns?: Array<string>;

54

testTimeout?: number;

55

56

// Coverage configuration

57

collectCoverage?: boolean;

58

collectCoverageFrom?: Array<string>;

59

coverageDirectory?: string;

60

coveragePathIgnorePatterns?: Array<string>;

61

coverageProvider?: CoverageProvider;

62

coverageReporters?: CoverageReporters;

63

coverageThreshold?: CoverageThreshold;

64

65

// Module configuration

66

moduleDirectories?: Array<string>;

67

moduleFileExtensions?: Array<string>;

68

moduleNameMapper?: Record<string, string | Array<string>>;

69

modulePathIgnorePatterns?: Array<string>;

70

modulePaths?: Array<string>;

71

72

// Transform configuration

73

transform?: Record<string, string | [string, Record<string, unknown>]>;

74

transformIgnorePatterns?: Array<string>;

75

76

// Fake timers

77

fakeTimers?: FakeTimers;

78

79

// Setup and teardown

80

setupFiles?: Array<string>;

81

setupFilesAfterEnv?: Array<string>;

82

globalSetup?: string;

83

globalTeardown?: string;

84

85

// Mocking

86

automock?: boolean;

87

clearMocks?: boolean;

88

resetMocks?: boolean;

89

restoreMocks?: boolean;

90

91

// Miscellaneous

92

bail?: boolean | number;

93

cache?: boolean;

94

cacheDirectory?: string;

95

maxWorkers?: number | string;

96

verbose?: boolean;

97

silent?: boolean;

98

99

// Jest-specific

100

roots?: Array<string>;

101

testRunner?: string;

102

testSequencer?: string;

103

}

104

```

105

106

### Fake Timers Configuration

107

108

Comprehensive fake timers configuration types for controlling Jest's timer mocking.

109

110

```typescript { .api }

111

/**

112

* APIs that can be faked by Jest's fake timers

113

*/

114

type FakeableAPI =

115

| 'Date'

116

| 'hrtime'

117

| 'nextTick'

118

| 'performance'

119

| 'queueMicrotask'

120

| 'requestAnimationFrame'

121

| 'cancelAnimationFrame'

122

| 'requestIdleCallback'

123

| 'cancelIdleCallback'

124

| 'setImmediate'

125

| 'clearImmediate'

126

| 'setInterval'

127

| 'clearInterval'

128

| 'setTimeout'

129

| 'clearTimeout';

130

131

/**

132

* Global fake timers configuration

133

*/

134

type GlobalFakeTimersConfig = {

135

/**

136

* Whether fake timers should be enabled globally for all test files

137

* @defaultValue false

138

*/

139

enableGlobally?: boolean;

140

};

141

142

/**

143

* Modern fake timers configuration

144

*/

145

type FakeTimersConfig = {

146

/**

147

* If set to true, all timers will be advanced automatically by 20ms every 20ms.

148

* A custom time delta may be provided by passing a number.

149

* @defaultValue false

150

*/

151

advanceTimers?: boolean | number;

152

153

/**

154

* List of APIs that should not be faked

155

* @defaultValue []

156

*/

157

doNotFake?: Array<FakeableAPI>;

158

159

/**

160

* Sets current system time to be used by fake timers, in milliseconds

161

* @defaultValue Date.now()

162

*/

163

now?: number | Date;

164

165

/**

166

* Maximum number of recursive timers when calling jest.runAllTimers()

167

* @defaultValue 100_000

168

*/

169

timerLimit?: number;

170

171

/**

172

* Use old fake timers implementation instead of @sinonjs/fake-timers

173

* @defaultValue false

174

*/

175

legacyFakeTimers?: false;

176

};

177

178

/**

179

* Legacy fake timers configuration

180

*/

181

type LegacyFakeTimersConfig = {

182

/**

183

* Use old fake timers implementation

184

* @defaultValue false

185

*/

186

legacyFakeTimers?: true;

187

};

188

189

/**

190

* Combined fake timers configuration

191

*/

192

type FakeTimers = GlobalFakeTimersConfig &

193

(

194

| (FakeTimersConfig & {

195

now?: Exclude<FakeTimersConfig['now'], Date>;

196

})

197

| LegacyFakeTimersConfig

198

);

199

```

200

201

### Coverage Configuration

202

203

Types for Jest's code coverage configuration and reporting.

204

205

```typescript { .api }

206

/**

207

* Coverage provider options

208

*/

209

type CoverageProvider = 'babel' | 'v8';

210

211

/**

212

* Coverage reporter names

213

*/

214

type CoverageReporterName = keyof ReportOptions;

215

216

/**

217

* Coverage reporter with options

218

*/

219

type CoverageReporterWithOptions<K = CoverageReporterName> =

220

K extends CoverageReporterName

221

? ReportOptions[K] extends never

222

? never

223

: [K, Partial<ReportOptions[K]>]

224

: never;

225

226

/**

227

* Array of coverage reporters

228

*/

229

type CoverageReporters = Array<CoverageReporterName | CoverageReporterWithOptions>;

230

231

/**

232

* Coverage threshold values

233

*/

234

type CoverageThresholdValue = {

235

branches?: number;

236

functions?: number;

237

lines?: number;

238

statements?: number;

239

};

240

241

/**

242

* Coverage threshold configuration by file pattern

243

*/

244

type CoverageThreshold = {

245

[path: string]: CoverageThresholdValue;

246

global: CoverageThresholdValue;

247

};

248

```

249

250

### Module System Configuration

251

252

Types for Jest's Haste module system and module resolution.

253

254

```typescript { .api }

255

/**

256

* Haste module system configuration

257

*/

258

type HasteConfig = {

259

/** Whether to hash files using SHA-1 */

260

computeSha1?: boolean;

261

262

/** The platform to use as default, e.g. 'ios' */

263

defaultPlatform?: string | null;

264

265

/** Force use of Node's fs APIs rather than shelling out to find */

266

forceNodeFilesystemAPI?: boolean;

267

268

/**

269

* Whether to follow symlinks when crawling for files.

270

* Cannot be used in projects with watchman set to true.

271

*/

272

enableSymlinks?: boolean;

273

274

/** String to a custom implementation of Haste */

275

hasteImplModulePath?: string;

276

277

/** All platforms to target, e.g ['ios', 'android'] */

278

platforms?: Array<string>;

279

280

/** Whether to throw an error on module collision */

281

throwOnModuleCollision?: boolean;

282

283

/** Custom HasteMap module */

284

hasteMapModulePath?: string;

285

286

/** Whether to retain all files, allowing e.g. search for tests in node_modules */

287

retainAllFiles?: boolean;

288

};

289

```

290

291

### Configuration Types

292

293

Additional configuration-related types and interfaces.

294

295

```typescript { .api }

296

/**

297

* Reporter configuration tuple

298

*/

299

type ReporterConfig = [string, Record<string, unknown>];

300

301

/**

302

* Transformer configuration tuple

303

*/

304

type TransformerConfig = [string, Record<string, unknown>];

305

306

/**

307

* Global variables configuration

308

*/

309

interface ConfigGlobals {

310

[K: string]: unknown;

311

}

312

313

/**

314

* Display name configuration for projects

315

*/

316

type DisplayName = {

317

name: string;

318

color: typeof ForegroundColor;

319

};

320

321

/**

322

* Snapshot update state options

323

*/

324

type SnapshotUpdateState = 'all' | 'new' | 'none';

325

326

/**

327

* Notification mode options

328

*/

329

type NotifyMode =

330

| 'always'

331

| 'failure'

332

| 'success'

333

| 'change'

334

| 'success-change'

335

| 'failure-change';

336

337

/**

338

* Test sharding configuration

339

*/

340

type ShardConfig = {

341

shardIndex: number;

342

shardCount: number;

343

};

344

```

345

346

### Runtime Configuration Interfaces

347

348

Configuration interfaces used during Jest execution.

349

350

```typescript { .api }

351

/**

352

* Global configuration for Jest execution

353

*/

354

interface GlobalConfig {

355

bail: number;

356

changedSince?: string;

357

changedFilesWithAncestor: boolean;

358

ci: boolean;

359

collectCoverage: boolean;

360

collectCoverageFrom: Array<string>;

361

coverageDirectory: string;

362

coveragePathIgnorePatterns?: Array<string>;

363

coverageProvider: CoverageProvider;

364

coverageReporters: CoverageReporters;

365

coverageThreshold?: CoverageThreshold;

366

detectLeaks: boolean;

367

detectOpenHandles: boolean;

368

expand: boolean;

369

filter?: string;

370

findRelatedTests: boolean;

371

forceExit: boolean;

372

json: boolean;

373

globalSetup?: string;

374

globalTeardown?: string;

375

lastCommit: boolean;

376

logHeapUsage: boolean;

377

listTests: boolean;

378

maxConcurrency: number;

379

maxWorkers: number;

380

noStackTrace: boolean;

381

nonFlagArgs: Array<string>;

382

noSCM?: boolean;

383

notify: boolean;

384

notifyMode: NotifyMode;

385

outputFile?: string;

386

onlyChanged: boolean;

387

onlyFailures: boolean;

388

openHandlesTimeout: number;

389

passWithNoTests: boolean;

390

projects: Array<string>;

391

randomize?: boolean;

392

replname?: string;

393

reporters?: Array<ReporterConfig>;

394

runInBand: boolean;

395

runTestsByPath: boolean;

396

rootDir: string;

397

seed: number;

398

showSeed?: boolean;

399

shard?: ShardConfig;

400

silent?: boolean;

401

skipFilter: boolean;

402

snapshotFormat: SnapshotFormat;

403

errorOnDeprecated: boolean;

404

testFailureExitCode: number;

405

testNamePattern?: string;

406

testPathPatterns: TestPathPatterns;

407

testResultsProcessor?: string;

408

testSequencer: string;

409

testTimeout?: number;

410

updateSnapshot: SnapshotUpdateState;

411

useStderr: boolean;

412

verbose?: boolean;

413

waitForUnhandledRejections: boolean;

414

watch: boolean;

415

watchAll: boolean;

416

watchman: boolean;

417

watchPlugins?: Array<{

418

path: string;

419

config: Record<string, unknown>;

420

}> | null;

421

workerIdleMemoryLimit?: number;

422

workerThreads?: boolean;

423

}

424

425

/**

426

* Project-specific configuration

427

*/

428

interface ProjectConfig {

429

automock: boolean;

430

cache: boolean;

431

cacheDirectory: string;

432

clearMocks: boolean;

433

collectCoverageFrom: Array<string>;

434

coverageDirectory: string;

435

coveragePathIgnorePatterns: Array<string>;

436

coverageReporters: CoverageReporters;

437

cwd: string;

438

dependencyExtractor?: string;

439

detectLeaks: boolean;

440

detectOpenHandles: boolean;

441

displayName?: DisplayName;

442

errorOnDeprecated: boolean;

443

extensionsToTreatAsEsm: Array<string>;

444

fakeTimers: FakeTimers;

445

filter?: string;

446

forceCoverageMatch: Array<string>;

447

globalSetup?: string;

448

globalTeardown?: string;

449

globals: ConfigGlobals;

450

haste: HasteConfig;

451

id: string;

452

injectGlobals: boolean;

453

moduleDirectories: Array<string>;

454

moduleFileExtensions: Array<string>;

455

moduleNameMapper: Array<[string, string]>;

456

modulePathIgnorePatterns: Array<string>;

457

modulePaths?: Array<string>;

458

openHandlesTimeout: number;

459

preset?: string;

460

prettierPath: string;

461

reporters: Array<string | ReporterConfig>;

462

resetMocks: boolean;

463

resetModules: boolean;

464

resolver?: string;

465

restoreMocks: boolean;

466

rootDir: string;

467

roots: Array<string>;

468

runner: string;

469

runtime?: string;

470

sandboxInjectedGlobals: Array<keyof typeof globalThis>;

471

setupFiles: Array<string>;

472

setupFilesAfterEnv: Array<string>;

473

skipFilter: boolean;

474

skipNodeResolution?: boolean;

475

slowTestThreshold: number;

476

snapshotResolver?: string;

477

snapshotSerializers: Array<string>;

478

snapshotFormat: SnapshotFormat;

479

testEnvironment: string;

480

testEnvironmentOptions: Record<string, unknown>;

481

testMatch: Array<string>;

482

testLocationInResults: boolean;

483

testPathIgnorePatterns: Array<string>;

484

testRegex: Array<string | RegExp>;

485

testRunner: string;

486

testTimeout: number;

487

transform: Array<[string, string, Record<string, unknown>]>;

488

transformIgnorePatterns: Array<string>;

489

watchPathIgnorePatterns: Array<string>;

490

unmockedModulePathPatterns?: Array<string>;

491

waitForUnhandledRejections: boolean;

492

workerIdleMemoryLimit?: number;

493

}

494

```

495

496

### CLI Arguments Type

497

498

Comprehensive type for Jest CLI arguments.

499

500

```typescript { .api }

501

/**

502

* Jest CLI arguments type

503

*/

504

type Argv = Arguments<

505

Partial<{

506

all: boolean;

507

automock: boolean;

508

bail: boolean | number;

509

cache: boolean;

510

cacheDirectory: string;

511

changedFilesWithAncestor: boolean;

512

changedSince: string;

513

ci: boolean;

514

clearCache: boolean;

515

clearMocks: boolean;

516

collectCoverage: boolean;

517

collectCoverageFrom: string;

518

color: boolean;

519

colors: boolean;

520

config: string;

521

coverage: boolean;

522

coverageDirectory: string;

523

coveragePathIgnorePatterns: Array<string>;

524

coverageReporters: Array<string>;

525

coverageThreshold: string;

526

debug: boolean;

527

env: string;

528

expand: boolean;

529

findRelatedTests: boolean;

530

forceExit: boolean;

531

globals: string;

532

globalSetup: string | null | undefined;

533

globalTeardown: string | null | undefined;

534

haste: string;

535

ignoreProjects: Array<string>;

536

injectGlobals: boolean;

537

json: boolean;

538

lastCommit: boolean;

539

logHeapUsage: boolean;

540

maxWorkers: number | string;

541

moduleDirectories: Array<string>;

542

moduleFileExtensions: Array<string>;

543

moduleNameMapper: string;

544

modulePathIgnorePatterns: Array<string>;

545

modulePaths: Array<string>;

546

noStackTrace: boolean;

547

notify: boolean;

548

notifyMode: string;

549

onlyChanged: boolean;

550

onlyFailures: boolean;

551

outputFile: string;

552

preset: string | null | undefined;

553

prettierPath: string | null | undefined;

554

projects: Array<string>;

555

randomize: boolean;

556

reporters: Array<string>;

557

resetMocks: boolean;

558

resetModules: boolean;

559

resolver: string | null | undefined;

560

restoreMocks: boolean;

561

rootDir: string;

562

roots: Array<string>;

563

runInBand: boolean;

564

seed: number;

565

showSeed: boolean;

566

selectProjects: Array<string>;

567

setupFiles: Array<string>;

568

setupFilesAfterEnv: Array<string>;

569

shard: string;

570

showConfig: boolean;

571

silent: boolean;

572

snapshotSerializers: Array<string>;

573

testEnvironment: string;

574

testEnvironmentOptions: string;

575

testFailureExitCode: string | null | undefined;

576

testMatch: string | Array<string>;

577

testNamePattern: string;

578

testPathIgnorePatterns: Array<string>;

579

testPathPatterns: Array<string>;

580

testRegex: string | Array<string>;

581

testResultsProcessor: string;

582

testRunner: string;

583

testSequencer: string;

584

testTimeout: number | null | undefined;

585

transform: string;

586

transformIgnorePatterns: Array<string>;

587

unmockedModulePathPatterns: Array<string> | null | undefined;

588

updateSnapshot: boolean;

589

useStderr: boolean;

590

verbose: boolean;

591

version: boolean;

592

watch: boolean;

593

watchAll: boolean;

594

watchman: boolean;

595

watchPathIgnorePatterns: Array<string>;

596

workerIdleMemoryLimit: number | string;

597

workerThreads: boolean;

598

}>

599

>;

600

```

601

602

**Usage Examples:**

603

604

```typescript

605

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

606

607

// Basic Jest configuration

608

const jestConfig: Config.InitialOptions = {

609

testEnvironment: "node",

610

collectCoverage: true,

611

coverageDirectory: "coverage",

612

coverageReporters: ["text", "lcov", "html"],

613

testMatch: ["**/__tests__/**/*.test.ts"],

614

transform: {

615

"^.+\\.ts$": "ts-jest",

616

},

617

};

618

619

// Fake timers configuration

620

const timerConfig: Config.FakeTimersConfig = {

621

enableGlobally: true,

622

advanceTimers: true,

623

doNotFake: ["performance", "Date"],

624

timerLimit: 50000,

625

};

626

627

// Coverage threshold configuration

628

const coverageThreshold: Config.CoverageThreshold = {

629

global: {

630

branches: 80,

631

functions: 80,

632

lines: 80,

633

statements: 80,

634

},

635

"./src/utils/": {

636

branches: 90,

637

functions: 90,

638

},

639

};

640

```