Typically we end up testing the Lambda function directly as unit tests. But maybe you are looking for integration testing?
Correct, I’m trying to implement a proper integration testing.
Yeah we haven’t covered it here. That might be something we look at in the future.
Thank you Jayair,
That’s pitty, as this tutorial is seriously the best one I could see anywhere on innternet and integration testing is an important task to accomplish in software development workflow.
On intenet I could not find any solution I liked when it comes to integration/acceptance testing using serverless without breaking the CI/CD workflow, so I ended up defining a pattern myself.
I dunno if it is the best way to do it but it is working well for my use case where I had other services to integrate and test on top of dynamoDB (ie. appsync graphql endpoints).
Basically, I used aws sdk to remotely login a test user and then get the deployed endpoints to be tested from a lambda which gets them from a cloudFormation stack output i.e.:
and returns it to the integration-test when invoked.
The solution gives me a very high degree of confidence that all services are working well together and doesn’t break the CI/CD workflow everytime an endpoint is changed or added to the service.
On Seed platform worked like a charm.
Awesome! Yeah that makes sense. Thanks for sharing!
I also ran into the “SyntaxError: Cannot use import statement outside a module” error. CommonJS style imports did the trick.
I’m using a v4.0 pdf of the tutorial that has Jest as the test runner. Reading up on the comments below, it sounds like there might be a new version of the tutorial using plug-in to run tests.