https://github.com/abhi11210646/fake-json-generator
Generate JSON data for testing purpose
https://github.com/abhi11210646/fake-json-generator
fake-data fs json test-data-generator
Last synced: 3 months ago
JSON representation
Generate JSON data for testing purpose
- Host: GitHub
- URL: https://github.com/abhi11210646/fake-json-generator
- Owner: abhi11210646
- Created: 2018-06-05T18:32:44.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-06T17:26:31.000Z (about 8 years ago)
- Last Synced: 2025-01-05T09:30:38.228Z (over 1 year ago)
- Topics: fake-data, fs, json, test-data-generator
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/fake-json-generator
- Size: 49.8 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fake JSON generator
> Fake JSON generator for playing with nodeJs fs module, testing redis cache,for creating fake REST API etc.
## Installation
```
$ npm i fake-json-generator
```
## Usage
**Note** Keep json file in the same directory. And provide full path for JSON file.
It exposes synchronous and asynchronous methods.
```js
/**
fakeJSON expect 2 argument first one is path and second one is number of JSON Object.
e.g. fakeJSON(path, No_Of_JSON_obj);
**/
const { fakeJSONSync, fakeJSON } = require("fake-json-generator");
// Asynchronous
fakeJSON(`${__dirname}/fake-JSON.json`, 200)
.then((res) => console.log('RESPONSE', res))
.catch(err => console.log('ERROR', err));
// Synchronous
const ss = fakeJSONSync(`${__dirname}/fake-JSON.json`, 100);
### Output
[
{ "_id": 828181167,
"title": "Sir",
"firstName": "Richelle",
"lastName": "Charley",
"favouriteColor": "lightseagreen",
"about": "finibus maecenas dignissim vel blandit placerat sed tempor ex faucibus ...",
"address": {
"street": "Pitman Street",
"city": "Manchester",
"country": "Bermuda",
"countryCode": "BM"
},
"company": "LoopSys",
"contactDetails": {
"phone": "(488)-(869)-(240)",
"email": "Richelle.Charley@LoopSys.com"
}
},
...
,
...
]
```