How to use the mocker-data-generator function in mocker-data-generator

To help you get started, we’ve selected a few mocker-data-generator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unleashit / npm-library / packages / mockData / src / index.ts View on Github external
const mockData = async ({
  template = null,
  templates = null,
  total = 10,
  name = null,
  args = {},
  path = null,
  hiddenFields = [],
}: MockDataArguments): Promise => {
  /* eslint-disable no-param-reassign */
  const m = mocker();

  try {
    if (template) {
      // single schema
      if (typeof template !== 'function' && Object.keys(tpl).indexOf(template) === -1) {
        throw new Error('That template does not exist');
      }

      if (hiddenFields.length) args.hiddenFields = hiddenFields;
      const modelName = name || (typeof template === 'string' && template) || 'data';
      const processedTemplate = processTemplate(template, args);

      m.schema(modelName, processedTemplate, total);
    } else if (templates) {
      // multiple schemas
      templates.forEach((tmpl: any, i: number): void => {

mocker-data-generator

A simplified way to generate mock data, builds using a simple schema and with the FakerJs

MIT
Latest version published 12 months ago

Package Health Score

64 / 100
Full package analysis

Popular mocker-data-generator functions