mockado
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

Mockado

Have fictitious yet realistic data for your development tests or other needs.

npm version npm downloads

Built with

nodejs typescript

🚀 Features

  • 📅 Dates in different formats - YYYY-MM-DD, DD/MM/YYYY, DD MMM YYYY, YYYY-MM-DD HH:mm:ss
  • 🪪 Identification - CPF, SSN, SIN.
  • 📧 Emails on different domains - gmail.com, hotmail.com, yahoo.com.
  • 🧑 Names based on usability - first name, full name or username.
  • 🔑 Password with whatever charset you want - With or without letters, with or without special characters, with or without numbers.
  • 🌏 Location - A complete location or just the street, neighborhood, state or zipCode.
  • 📱 Phone number - Numbers in BRA or US format.

Note: The data generated seeks to be as realistic as possible, without being obvious. It is possible that real emails, phone numbers or addresses will be generated. Use them responsibly. Don't implement anything in your code that could upset the owners of this data.

📦 Install

npm install --save-dev mockado

🪄 Usage

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

export function createRandomUser() {
  return {
    username: mockado.name({type: "username"}),
    email: mockado.email(),
    password: mockado.password(),
    birthdate: mockado.date(),
  };
}

Scenarios

Mockado always returns default data. To receive personalized data, you need to pass your preferences as a parameter. The type of data returned varies depending on the function called.

First name

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const firstName = mockado.name({type: "firstName"});

console.log(`Hello my name is ${firstName}`);

// output: Hello my name is Ethan

First name with choice of gender

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const firstName = mockado.name({type: "firstName", gender: "female"});

console.log(`Hello my name is ${firstName}`);

// output: Hello my name is Naomi

Full name

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const fullName = mockado.name({type: "fullName"});

console.log(`Hello my name is ${fullName}`);

// output: Hello my name is Casey Pacheco

username

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const username = mockado.name({type: "username"});

console.log(`Hi, my username is ${username}`);

// output: Hi, my username is matthew715

Email

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const email = mockado.email();

console.log(email);

// output: william96@gmail.com

Email with defined domain

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const email = mockado.email({type: "yahoo.com"});

console.log(email);

// output: patrick162@yahoo.com

Email with defined domain and gender

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const email = mockado.email({type: "yahoo.com", gender: "female"});

console.log(email);

// output: ella648@yahoo.com

Password

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const password = mockado.password();

console.log(password);

// output: Dkoq>kfk

Custom password

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const password = mockado.password({
  letters: true,
  capitalLetters: true,
  numbers: false,
  specialCharacters: true,
  length: 21,
})

console.log(password)

// output: mXjQbfFOMOAbkfejXUoE&

Date

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const date = mockado.date();

console.log(date)

// output: 1974-01-24

Date with custom format

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const date = mockado.date({format: "DD MMM YYYY"});

console.log(date)

// 02 Dec 1994

Date between a specified start and end

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const date = mockado.date({
  start: new Date(1995, 0, 1),
  end: new Date(2018, 0, 1),
})

console.log(date)

// 2011-10-11

Phone number

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const phone = mockado.phone()

console.log(phone)

// +55 89 81370-2069

Telephone number with specified code

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const phone = mockado.phone({code: "EUA"})

console.log(phone)

// +1 730 773-6805

Location

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const location = mockado.location()

console.log(location)

// Estr. das Paineiras, 1 - Alto da Boa Vista, Rio de Janeiro - Rio de Janeiro, 22241-330

Get just the street

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const location = mockado.location("street")

console.log(location)

// Praça XV de Novembro

Get just the zipCode

// ESM
import mockado from 'mockado';

// CJS
const mockado = require('mockado');

const location = mockado.location("zipCode")

console.log(location)

// 51011-000

Package Sidebar

Install

npm i mockado

Weekly Downloads

7

Version

2.0.3

License

ISC

Unpacked Size

43.2 kB

Total Files

24

Last publish

Collaborators

  • luizfelipegois