-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambdaTest.js
More file actions
42 lines (35 loc) · 995 Bytes
/
lambdaTest.js
File metadata and controls
42 lines (35 loc) · 995 Bytes
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
const lambdaHandler = require('./build/mainFunc.js').lambdaHandler;
const createMockContext = require('aws-lambda-mock-context');
// This file is used for quick testing of the API function, within the IDE.
// It must first be compiled with tsc, then run with node.
const mockContext = createMockContext();
const mockEvent = {
body: JSON.stringify({
actor1: 17142,
actor2: 3063,
}),
};
// const mockEvent = {
// body: JSON.stringify({
// actor1: null,
// actor2: null,
// guess: null,
// }),
// };
async function testLambdaHandler() {
try {
const result = await lambdaHandler(mockEvent, mockContext);
console.log('🧪 ✅ RESULT:');
console.log(result);
if (result.statusCode === 200 && result.body) {
mockContext.succeed(result);
} else {
mockContext.fail(new Error('Invalid result'));
}
} catch (err) {
console.log('🧪 🚨 ERROR:');
console.error(err);
mockContext.fail(err);
}
}
testLambdaHandler();