All Projects → Goldziher → interface-forge

Goldziher / interface-forge

Licence: MIT license
Graceful mock-data and fixtures generation using TypeScript

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to interface-forge

factory
Generate lots of mock API data with ease.
Stars: ✭ 17 (-70.69%)
Mutual labels:  mock, mock-data
main
Mocks Server monorepo
Stars: ✭ 109 (+87.93%)
Mutual labels:  mock, fixtures
Foundry
A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.
Stars: ✭ 216 (+272.41%)
Mutual labels:  factory, fixtures
Model mommy
No longer maintained, please migrate to model_bakery
Stars: ✭ 929 (+1501.72%)
Mutual labels:  factory, fixtures
Mimesis
Mimesis is a high-performance fake data generator for Python, which provides data for a variety of purposes in a variety of languages.
Stars: ✭ 3,439 (+5829.31%)
Mutual labels:  mock, fixtures
miz
🎯 Generate fake data, Just like a person.
Stars: ✭ 24 (-58.62%)
Mutual labels:  mock, mock-data
mock-data
Mock data in PostgreSQL/Greenplum databases
Stars: ✭ 115 (+98.28%)
Mutual labels:  mock, mock-data
mockingbird
🐦 Decorator Powered TypeScript Library for Creating Mocks
Stars: ✭ 70 (+20.69%)
Mutual labels:  mock, fixtures
ng-apimock
Node plugin that provides the ability to use scenario based api mocking: for local development for protractor testing
Stars: ✭ 102 (+75.86%)
Mutual labels:  mock, mock-data
better-mock
Forked from Mockjs, Generate random data & Intercept ajax request. Support miniprogram.
Stars: ✭ 140 (+141.38%)
Mutual labels:  mock, mock-data
Mockoon
Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source.
Stars: ✭ 3,448 (+5844.83%)
Mutual labels:  mock, mock-data
fe-dev-server
FE Dev Server target to help frontend web developers create view template, styles and js easily.
Stars: ✭ 30 (-48.28%)
Mutual labels:  mock, mock-data
ruby-dns-mock
DNS mock server written on 💎 Ruby. Mimic any DNS records for your test environment with fake DNS server.
Stars: ✭ 50 (-13.79%)
Mutual labels:  mock
dextool
Suite of C/C++ tooling built on LLVM/Clang
Stars: ✭ 81 (+39.66%)
Mutual labels:  mock
web3-mock
🤡 JavaScript library to mock web3 responses either by emulating web3 wallets or web3 RPC requests.
Stars: ✭ 54 (-6.9%)
Mutual labels:  mock
ersatz
🤖 A simulated HTTP server for testing client code with configurable responses.
Stars: ✭ 44 (-24.14%)
Mutual labels:  mock
chip
📦 🐳 🚀 - Smart "dummy" mock for cloud native tests
Stars: ✭ 19 (-67.24%)
Mutual labels:  mock
moq.ts
Moq for Typescript
Stars: ✭ 107 (+84.48%)
Mutual labels:  mock
json-fake-server
Simple way to create http server (node js) https://www.npmjs.com/package/test-fake-server
Stars: ✭ 15 (-74.14%)
Mutual labels:  mock
mock-webpack-plugin
A webpack plugin that starts a json mock server
Stars: ✭ 21 (-63.79%)
Mutual labels:  mock-data

NPM

Coverage Duplicated Lines (%) Maintainability Rating Reliability Rating Technical Debt Code Smells Bugs

All Contributors

Interface-Forge allows you to gracefully generate dynamic mock data and static fixtures in TypeScript.


Installation

yarn add --dev interface-forge

Or

npm install --save-dev interface-forge

Basic Example

To create a factory you need some TS types:

// types.ts

export interface UserProfile {
    profession: string;
    gender: string;
    age: number;
}

export interface Cat {
    name: string;
}

export interface User {
    firstName: string;
    lastName: string;
    email: string;
    profile: UserProfile;
    cats: Cat[];
}

Pass the desired type as a generic argument when instantiating TypeFactory, alongside default values for the factory:

// factories.ts
import { TypeFactory } from 'interface-forge';
import { User } from './types';

// i is type number
const UserFactory = new TypeFactory<User>((i) => ({
    firstName: 'John',
    lastName: 'Smith',
    email: '[email protected]',
    profile: {
        profession: 'cook',
        gender: 'male',
        age: 27 + i,
    },
    cats: [],
}));

Then use the factory to create an object of the desired type in a test file:

// User.spec.ts

describe('User', () => {
    // you can pass override values when calling build
    const user = UserFactory.buildSync({
        firstName: 'Johanne',
        profile: {
            profession: 'Journalist',
            gender: 'Female',
            age: 31,
        },
        cats: [],
    });
    // user == {
    //     firstName: "Johanne",
    //     lastName: "Smith",
    //     email: "[email protected]",
    //     profile: {
    //         profession: "Journalist",
    //         gender: "Female",
    //         age: 31
    //     },
    //     cats: []
    // }
    // ...
});

Take a look at our documentation or read the introduction article .

Contributing & Contributors

Thanks goes to these wonderful people (emoji key):


Na'aman Hirschfeld

💻 📖 🚧

Damian

💻 📖 🚧

Yannis Kommana

💻

This project follows the all-contributors specification. Contributions of any kind welcome! Please see the contributing guide.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].