A flexible tool for generating customizable mock data with a fluent interface that is a part of @fluentfixture project.
Introduction
A flexible tool for generating customizable mock data with a fluent interface that is a part of the @fluentfixture project.
Provides core modules and components for generating mock data.
Installation
$ npm install @fluentfixture/core
Usage
import { alphabetic, bool, hex, int, obj, pick } from '@fluentfixture/core';
const price = obj({
amount: int(1, 100),
currency: pick(['USD', 'EUR', 'GBP', 'TRY']),
});
const color = hex(6).padStart(7, '#').upperCase();
const product = obj({
id: int(1, 999),
name: alphabetic(20).capitalCase(),
color: color,
price: price,
discount: price.optional(),
featured: bool(0.7),
});
const productWithCode = product
.lazy('code', (p) => `${p.id}-${p.color}`);
const products = productWithCode
.array(10)
.sort((a, b) => a.id - b.id);
console.log(products.single());
Documentation
To check out the guide, visit https://docs.fluentfixture.com/
License
@fluentfixture is MIT licensed.