Skip to content

Instantly share code, notes, and snippets.

@ulisesantana
Created December 18, 2019 16:50
Show Gist options
  • Save ulisesantana/b16a32b9bbc86e00a88490ac91c964b1 to your computer and use it in GitHub Desktop.
Save ulisesantana/b16a32b9bbc86e00a88490ac91c964b1 to your computer and use it in GitHub Desktop.
Mock generator
const { address, company, random } = require('faker');
const fs = require('fs');
const path = require('path');
fs.writeFile(
path.resolve('companies.mock.json'),
JSON.stringify(
[...new Array(60)].map(() => ({
id: random.number(),
name: company.companyName(),
country: address.country(),
active: random.boolean(),
})),
null,
2
),
{ encoding: 'utf8' },
err => {
if (err) {
console.error(err.toString());
throw err;
}
console.log('Mock created.');
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment