Forger Help

Auto-Generated Test Data for TypeScript

Forger is a lightweight library that forges fully populated objects of any TypeScript type. A single call — Forger.create<T>() — returns a realistic fake with every property filled in, so your tests contain only the data that really matters.

// interface Student { name: string; age: number } const student = Forger.create<Student>(); // { name: 'I8SE1ou3ZD', age: 345 }

1. The problem Forger solves

Test code drowns in data. Before anything can be asserted, a test has to build the object under test — and every object it references:

  • builders and factory helpers pile up next to the production code;

  • test bodies are littered with literals that mean nothing to the reader;

  • every new field in a class breaks dozens of hand-written stubs;

  • dummy values like name: 'test' mislead readers into thinking the data matters.

The result: tests are hard to write and harder to read, while the important part — the assertion — gets lost in the noise.

2. How Forger changes the picture

Forger generates the noise for you. Any type — interface, class, primitive, enum, array, tuple, function, union, generic — is forged automatically:

// interface Student { name: string; age: number; birthday: Date; friends: Student[] } describe('student.service', () => { it('save success', () => { const student = Forger.create<Student>(); // const result = studentService.save(student); // expect(result).toBeTruthy(); }); });

The test now shows what is important — the service call and the assertion. The data is present, valid, and random, exactly as test data should be.

Need a concrete value here and there? Pin it with createWith:

const student = Forger.createWith<Student>() .with(s => s.name = 'John Doe') .result();

3. Core concepts

Concept

Description

Link to section

Forger.create

Forge a fully populated value of any type.

Creating fakes

Forger.createWith

Forge a value and pin specific properties to concrete values.

createWith

Type support

Primitives, dates, enums, literals, unions, arrays, tuples, functions.

Supported types

Objects & generics

Interfaces, classes, inheritance chains, generic types, circular refs.

Objects

SpoofSettings

Tune how numbers, strings, dates, and arrays are generated.

Settings

Compile-time pipeline

A TypeScript transformer feeds type info to the runtime factories.

How it works

4. Quick example

import { Forger } from '@artstesh/forger'; interface Order { id: number; createdAt: Date; items: string[]; status: 'new' | 'paid' | 'shipped'; customer: { name: string; email: string }; } describe('order.service', () => { it('paid orders cannot be edited', () => { const order = Forger.createWith<Order>() .with(o => o.status = 'paid') .result(); // expect(orderService.canEdit(order)).toBe(false); }); });

Everything is populated: id is a number, createdAt a date, items an array of strings, customer a nested object — and status is pinned to the exact value the test is about.

5. Why choose Forger?

  • Any type, one call — from string to deeply nested generics with circular references.

  • Truly type-safe — the type is resolved at compile time by a TypeScript transformer, not guessed from runtime objects.

  • No setup surface — no builders, no fixtures, no registration; just call create<T>().

  • Tunable generation — ranges, lengths, and charsets through a single settings object.

  • Zero runtime dependencies — nothing but TypeScript in your peer dependencies.

  • Framework-agnostic — works with Jest, Karma, Angular, Webpack, or plain tsc builds.

6. Next steps

Forger keeps your tests about behavior — not about data.

08 September 2026