I just published a mock data library for javascript fluentfixture.
Why we made this?
Generating mock data is hard, and customizing the fake data is more challenging. Libraries like Faker provide rich and realistic data but lack fluent interface and extensibility. In this project, we aim to provide programmability and extensibility.
An E-Commerce Scenario
Create ten products. Each product's barcode must be similar to ids. Sort the products by id.
import { alphabetic, int, obj, pick } from '@fluentfixture/core';
const price = obj({
amount: int(1, 100),
currency: pick(['USD', 'EUR', 'GBP', 'TRY']),
});
const product = obj({
id: int(100, 999),
name: alphabetic(10).capitalCase(),
price
});
const productWithBarcode = product
.lazy('barcode', (p) => `##${p.id}`);
const products = productWithBarcode
.array(10)
.sort((p1, p2) => p1.id - p2.id);
console.log(
products.single(),
);
Links
Thank you for feedback and contributions :)
Top comments (0)