All Projects → meeshkan → Jaymock

meeshkan / Jaymock

Minimal fake JSON test data generator.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Jaymock

Mimesis
Mimesis is a high-performance fake data generator for Python, which provides data for a variety of purposes in a variety of languages.
Stars: ✭ 3,439 (+12182.14%)
Mutual labels:  json, fake, data, generator
Gofakeit
Random fake data generator written in go
Stars: ✭ 2,193 (+7732.14%)
Mutual labels:  fake, data, generator
Bogus
📇 A simple and sane fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.
Stars: ✭ 5,083 (+18053.57%)
Mutual labels:  fake, data, generator
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (+75%)
Mutual labels:  json, fake, data
Faker
Faker is a pure Elixir library for generating fake data.
Stars: ✭ 673 (+2303.57%)
Mutual labels:  data, generator, test
Http Fake Backend
Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 253 (+803.57%)
Mutual labels:  json, fake, data
Quranjson
Quran JSON ~ 6236 verses, 114 surah, 30 Juz
Stars: ✭ 278 (+892.86%)
Mutual labels:  json, data
Browser Compat Data
This repository contains compatibility data for Web technologies as displayed on MDN
Stars: ✭ 3,710 (+13150%)
Mutual labels:  json, data
Data
This repository contains general data for Web technologies
Stars: ✭ 418 (+1392.86%)
Mutual labels:  json, data
Coolie
Coolie(苦力) helps you to create models (& their constructors) from a JSON file.
Stars: ✭ 508 (+1714.29%)
Mutual labels:  json, generator
Panini
A super simple flat file generator.
Stars: ✭ 562 (+1907.14%)
Mutual labels:  json, data
Rest Assured
Java DSL for easy testing of REST services
Stars: ✭ 5,646 (+20064.29%)
Mutual labels:  json, test
falso
All the Fake Data for All Your Real Needs 🙂
Stars: ✭ 877 (+3032.14%)
Mutual labels:  data, fake
Tabulator
Interactive Tables and Data Grids for JavaScript
Stars: ✭ 4,329 (+15360.71%)
Mutual labels:  json, data
percona-qa
Percona QA is a suite of scripts and utilities that assists in building, continuous integration, automated testing & bug reporting for Percona Server, Percona XtraDB Cluster, Percona XtraBackup, Percona Server for MongoDB, as well as other flavors of MySQL (Oracle, Facebook MyQSL, WebScaleSQL, MariaDB) etc.
Stars: ✭ 55 (+96.43%)
Mutual labels:  generator, test
stub-server
Stub server for REST APIs
Stars: ✭ 14 (-50%)
Mutual labels:  test, fake
Sheetjs
📗 SheetJS Community Edition -- Spreadsheet Data Toolkit
Stars: ✭ 28,479 (+101610.71%)
Mutual labels:  json, data
Pytest Patterns
A couple of examples showing how pytest and its plugins can be combined to solve real-world needs.
Stars: ✭ 24 (-14.29%)
Mutual labels:  data, test
Kakajson
Fast conversion between JSON and model in Swift.
Stars: ✭ 867 (+2996.43%)
Mutual labels:  json, data
jaymock-cli
Mock an API and generate fake JSON test data, right from the terminal.
Stars: ✭ 13 (-53.57%)
Mutual labels:  test, fake

jaymock

Minimal fake JSON test data generator.

CircleCI XO Codecov

Install

~ ❯❯❯ npm install @meeshkanml/jaymock

Usage

const jaymock = require('@meeshkanml/jaymock')

const data = {
  firstName: 'name.firstName',
  lastName: 'name.lastName',
  ssn: 'ssn',
  address: {
    streetAddress: 'address.streetAddress',
    city: 'address.city',
    zipCode: 'address.zipCode'
  },
  emails: 'internet.email',
  ipAddress: 'internet.ip',
  _repeat: 2
}

const jm = jaymock()

const randExp = require('randexp').randexp
// Add custom functions using `.extend()`
jm.extend({
  ssn: () => randExp(/^\d{3}-\d{2}-\d{4}$/)
})

const fakeData = jm.populate(data)
/*
  [
    {
      firstName: 'Marguerite',
      lastName: 'Will',
      ssn: '076-86-6001',
      address: {
        streetAddress: '4509 Abernathy Port',
        city: 'Port Charles',
        zipCode: '26322'
      },
      emails: '[email protected]',
      ipAddress: '44.210.55.248'
    },
    {
      firstName: 'Fredrick',
      lastName: 'McClure',
      ssn: '610-42-4980',
      address: {
        streetAddress: '56363 Goyette Station',
        city: 'West Floydmouth',
        zipCode: '73634-6751'
      },
      emails: '[email protected]',
      ipAddress: '237.7.221.162'
    }
  ]
*/

Mock API using express

const jaymock = require('@meeshkanml/jaymock')
const express = require('express')

app = express()
app.use(express.json())

const jm = jaymock()
jm.extend('chance', new require('chance')())

app.post('/', (req, res) => res.json(jm.populate(req.body)))

app.listen(3000)

API

.populate(template)

Returns an object, populated with fake data.

template

Type: object

Each object's value can be one of Faker.js's API methods, in the format '{topic}.{subtopic}' (e.g. 'name.firstName') or a custom method, defined using the .extend function, in the format '{function_name}' or {function_name}.{nested_function_name} (e.g. 'foo' will call foo() and 'foo.bar' will call foo.bar()).

A fake value can be generated n times, into an array of n values, by including |n at the end of the individual object's method name (e.g. 'name.firstName|5' will generate an array, populated with 5 fake first names). This also works with custom functions, accordingly.

To use the faker.fake() method (which permits the combination of faker API methods), use the format 'fake({mustache_strings})' (e.g. 'fake({{name.lastName}}, {{name.firstName}} {{name.suffix}})').

.extend(name, body)

Adds a custom data generation function that can be called in the .populate template using the value of name.

name

Type: string

body

Type: function

.extend(functions)

Adds custom data generation functions that can be called in the .populate template using the value of each object key.

functions

Type: object

Each object key should be the relevant function's name and value the function's body (e.g. { 'chance': new require('chance')() }).

.setFakerLocale(locale)

Sets Faker.js's language locale.

locale

Type: string

Any of Faker.js's locale options.

.setFakerSeed(seed)

Sets Faker.js's randomness seed.

seed

Type: number

Related

Contributing

Thanks for wanting to contribute! We will soon have a contributing page detailing how to contribute. Meanwhile, feel free to star this repository, open issues, and ask for more features and support.

Please note that this project is governed by the Meeshkan Community Code of Conduct. By participating in this project, you agree to abide by its terms.

Credits

  • Faker.js is used as jaymock's core fake data generator.

License

MIT © Meeshkan

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].