Created
December 18, 2018 06:51
-
-
Save peeyu321/4661653a7def105445a071ac501b280c to your computer and use it in GitHub Desktop.
API Funcitonal testing file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const asyncer = require("async") | |
const fs = require("fs") | |
const request = require('request') | |
const equate = require('fast-deep-equal') | |
const arr = JSON.parse(fs.readFileSync('config.json')).data | |
exports.endpoint = async (event) => { | |
asyncer.mapSeries(arr, (item, cb)=>{ | |
request(item.input, (err, res, body) => { | |
if (err) { | |
cb(err) | |
} | |
// return {url: item.input.url, report: equate(res.body, item.output)} | |
cb(null, {url: item.input.url, report: equate(JSON.parse(body), item.output)}) | |
//matcher function | |
}) | |
}, (err, results)=>{ | |
console.log(err || results) | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment