-
Notifications
You must be signed in to change notification settings - Fork 18
/
test.js
42 lines (36 loc) · 828 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var app = require('./app');
var request = require('request');
var port = 479;
var server = require('http').createServer(app);
// Start the local server to simulate AWS Lambda
server.listen(port, function() {
console.log('Server started on port '+port);
var tests = {}
tests = {
api: function(endpoint, params, callback) {
request({
url: "http://localhost:"+port+endpoint,
method: "GET",
json: params,
headers: {
'local-test': 'true'
}
}, function(error, response, body) {
var output;
try {
output = JSON.parse(body);
} catch (e) {
output = body;
}
callback(JSON.stringify(output, null, 4));
});
},
run: function() {
tests.api('/', {}, function(response) {
console.log(response);
});
}
}
// Run the test
tests.run();
});