https://github.com/internap/js-jabstract
Test tool for overridable json fixtures in JS
https://github.com/internap/js-jabstract
Last synced: 5 months ago
JSON representation
Test tool for overridable json fixtures in JS
- Host: GitHub
- URL: https://github.com/internap/js-jabstract
- Owner: internap
- License: apache-2.0
- Created: 2017-11-21T21:16:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-15T15:04:53.000Z (over 7 years ago)
- Last Synced: 2025-08-20T12:07:34.869Z (10 months ago)
- Language: JavaScript
- Size: 19.5 KB
- Stars: 0
- Watchers: 8
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/internap/js-jabstract)
Javascript version of [jabstract](https://github.com/internap/jabstract)
# USAGE
Declare your json responses somewhere:
```
const jabstract = require('jabstract');
let apiResponse = jabstract({
... json-ish payload ...
});
```
Then use it in your tests by defining only relevant fields:
```
let response = apiResponse({
'key': 'value'
});
```
It even supports complex payloads!
```
let apiResponse = jabstract({
'client': {
'name': 'John doe',
'email': 'johndoe@example.org'
}
});
let response = apiResponse({
'client': {
'name': 'Baboon v2.0'
}
});
```
\* note that `apiResponse` will keep its default value. So you can mock multiple fixtures for the same payload
# Importing
If you need to use jabstract for es5 (old nodejs or browser/karma) you can use the `dist/jabstract-browser-es5.js` file included in the nodejs package