-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix headers; Small improvements; Add integration tests; #20
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 callback(null, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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'}
.