How to use the mocker-data-generator.default 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 Midburn / spark / seeds / gen / generator.js View on Github external
const mocker = require('mocker-data-generator').default(),
    EVENT_MOCK_SCHEMA = require('./mockSchema/events.schema'),
    USER_MOCK_SCHEMA = require('./mockSchema/users.schema'),
    CAMP_MOCK_SCHEMA = require('./mockSchema/camps.schema'),
    SUPPLIER_MOCK_SCHEMA = require('./mockSchema/suppliers.schema'),
    utils = require('../util/utils');

const generate = async (scale) => {
    if (scale > 30) {
        return Promise.reject('This scale is not yet supported');
    }
    const campCount = scale * 50;
    return new Promise(async (resolve, reject) => {
        // TODO - Currently only create single event - need to think about increment with `MIDBURN` text.
        await utils.preventPkErrors([EVENT_MOCK_SCHEMA, USER_MOCK_SCHEMA, CAMP_MOCK_SCHEMA, SUPPLIER_MOCK_SCHEMA]);
        mocker
            .schema(EVENT_MOCK_SCHEMA.NAME, EVENT_MOCK_SCHEMA.STRUCTURE, scale * 2)
github terascope / teraslice / packages / teraslice / spec / utils / data_utils-spec.js View on Github external
it('between formats will default to 01 January, 1970 UTC if start is missing', (done) => {
        const endDate = moment().add(2, 'h');
        const newDate = new Date(0);
        const opConfig = { format: 'isoBetween', end: endDate.format(), date_key: 'created' };
        const resultSchema = schema(opConfig);

        mocker()
            .schema('schema', resultSchema, 1)
            .build()
            .then((data) => {
                const finalResult = data.schema[0];
                expect(new Date(finalResult.created)).toBeLessThan(new Date(endDate.format()));
                expect(new Date(finalResult.created)).toBeGreaterThan(newDate);
                done();
            })
            .catch((err) => {
                fail(err);
                done();
            });
    });
github terascope / teraslice / packages / teraslice / lib / readers / elasticsearch_data_generator.js View on Github external
if (opConfig.stress_test) {
            return mocker()
                .schema('schema', dataSchema, 1)
                .build()
                .then((dataObj) => {
                    const results = [];
                    const data = dataObj.schema[0];
                    for (let i = 0; i < msg; i += 1) {
                        results.push(data);
                    }
                    return results;
                })
                .catch(err => Promise.reject(`could not generate data error: ${parseError(err)}`));
        }

        return mocker()
            .schema('schema', dataSchema, msg)
            .build()
            .then(dataObj => dataObj.schema)
            .catch(err => Promise.reject(`could not generate data error: ${parseError(err)}`));
    };
}

mocker-data-generator

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

MIT
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis

Popular mocker-data-generator functions