Fix headers; Small improvements; Add integration tests;#20
Fix headers; Small improvements; Add integration tests;#20D-Andreev wants to merge 5 commits intobuildbreakdo:masterfrom
Conversation
|
Thanks for the fix! New Happy to merge this with |
Probably it's because of the version. Still quite the difference. I have version |
| const fetch = require('node-fetch'); | ||
|
|
||
| let samProcess; | ||
| const port = 5000; |
There was a problem hiding this comment.
I know this port is used only for local development, but does it make sense to come from an environment variable, from .env file or something?
| const port = 5000; | ||
| let lambdaUrl = `http://127.0.0.1:${port}/`; | ||
| function localApiStarted(processOutput) { | ||
| // Example output when local function started - "Running on http://127.0.0.1:5000/" |
There was a problem hiding this comment.
beforeAll hook starts the function locally and waits for output that sam has started, so the tests can begin. Probably not ideal way of doing it, I'm open to suggestions how to do this better :)
| "start": "sam local start-api --port 5000", | ||
| "test:integration": "npm run build && jest --verbose=false --config ./jest.config.integration.js", | ||
| "test:watch:integration": "npm run build && jest --watch --verbose=false --config ./jest.config.integration.js", | ||
| "start": "sam local start-api --port 5000 2>&1 | tr \"\\r\" \"\\n\"", |
There was a problem hiding this comment.
Added this part 2>&1 | tr \"\\r\" \"\\n\" because the console.logs from inside the function were not shown. A workaround, but couldn't find anything better - #1359
| return createResponse(500, {error: {message: error.message}}); | ||
| } | ||
|
|
||
| return callback(null, { |
There was a problem hiding this comment.
When function is async the callback is not needed, you can just return result.
|
Hey @buildbreakdo, I made some small improvements and added an integration test. Can you take a look please? |
The key should be
headers, otherwise there is an exceptionInvalid lambda response received: Invalid API Gateway Response Keys: {'header'}.