Data mocking made fun
Disclaimer
NPM package isn't up to date
Documentation is still being written
Tests only cover a very small percentage of the code
install via npm
$ npm install --save mokapjs
or yarn
$ yarn add mokapjs
import { bool } from 'mokapjs';
const randomBool = mock(bool);
import { num } from 'mokapjs';
// Will generate a number between 2 and 5
const numGen = num(2, 5);
const randomNum = mock(numGen); // e.g: 3
// Generators are reusable
const randomNum2 = mock(numGen); // e.g: 5
You can also generate bounds programmatically
import { num } from 'mokapjs';
const minGen = num(1, 3);
const maxGen = num(10, 15);
// Will generate a number between randomly generated min & max
const numGen = num(minGen, maxGen);
const randomNum = mock(numGen); // e.g: 4
Utility to mock strings using regular expressions
import { str } from 'mokapjs';
const strGen = str(/[A-Z][0-9]/);
const randomStr = mock(strGen); // e.g: "D3"
const randomStr2 = mock(strGen); // e.g: "H5"
import { arr } from 'mokapjs';
const arrGen = arr();