Options
All
  • Public
  • Public/Protected
  • All
Menu

mockachino

Mockachino

  • Faker
  • Mocker
  • Mocha?
  • Mochachino?!

Mockachino logo

Generate mock data for your apps, take a sip and relax!

  • People
  • Addresses
  • Phone Numbers
  • Jobs
  • Sentences
  • Paragraphs
  • Texts
  • Cities
  • Picsum Image URLs
  • Picsum Image Blobs
  • Placeholder titles
  • Random Numbers
  • & more

Based on US data; other countries to come.

Usage

Browser

<script src="mockachino.min.js"></script>
<script>
    // no options provided
    let mocked = Mockachino.mock();
    // show mocked data in the console
    console.log(mocked.phoneNumber);
    /* Object { cityCode: "468", country: "us", countryCode: "+1", number: "4687012345", subNumber: "7012345", withAreaCode: "+14687012345" }
    */
</script>

Node

npm i -D mockachino

const mockachino = require('Mockachino');

// with no options provided
let mocked = Mockachino.mock({
    locale: 'us',
    person: {
        sex: 'man',
        height: 'short',
        age: '20s'
    }
});

console.log(mocked.person);

/*
Object { name: "Valentina", middlename: "Nevaeh", middleInitial: "N.", lastname: "Adams", initials: "V.A", email: "valentina.adams@hotmail.com", academicTitle:  "Prof.", sex: "woman", age: 23, height: "4.5", … }
*/

mockachino.mock options

Option Description
Locale Defines the locale the data should be based on. Defaults to 'us', more locales to come
Person Mock a person, define the person sex, age, and height
-- --
sex woman, man
height tall, short
age young, old, 20s, 30s

mockachino.random usage

Data Description Usage
Number Just a random number Mockachino.random(200, 15).number; // A random number from 15 to 199
Title A random placeholder title Mockachino.random('-').title; // A-random-title separated by '-'
ImageUrl A random image URL from Picsum Mockachino.random(350, 300).imageUrl; // A random image URL of 350x300 size from Picsum
ImageBlob A random image blob from Picsum Mockachino.random(400, 500).imageBlob; // A random image Blob of 400x500 size from Picsum

Read more

Status

Build Status

Coverage Status

Shout outs

Contribute

  • Follow CONTRIBUTING.md
  • Rules of Conduct Contributor Covenant

Licence

The MIT License MIT

Author

© 2018 Simao Nziaka

Generated using TypeDoc