Hey are there any plans on writing docs about end ...
# sst
t
Hey are there any plans on writing docs about end to end testing sst apps?
t
I'm not sure anyone is an expert in this yet haha. It's an area I want to explore more
Been spending more of my time working on SST and less time using SST so haven't been able to get to that yet
o
@Thomas Ankcorn do you mean tests that - for example - call an external API, and wait check the response, or if it’s an async API test that the task gets completed within X time with the expected external behaviour?
t
Yeah most of the stuff I am looking at would be async.
o
Yeah, we use
p-wait-for
to poll the API for an update within the timeout - is there anything SST specific about end to end testing*?
t
oh cool that library looks useful, thanks for sharing. we have been using this https://github.com/erezrokah/aws-testing-library
o
Ah interesting, this seems like it could be useful at the integration test level. Those tests for us today don’t assert against AWS - just the return of the function, and we have the function return its side effects (e.g. return the message it put this queue) and assert against that. We’ve also been playing around with dependency injection and having the function take in functions to call whenever it needs to execute a side effect (e.g. putEvent, sendMessage). We then give it mock versions in tests. Haven’t been a huge fan so far though. The tests are super fast and reliable, but the mocking would be crazy for functions that have a lot of side effects, and the code becomes much harder to read, refactor and reason about.
t
so we have loads of unit tests that use lots of dependency injection. We use this library to help make the dependency injection for our functions more standardised https://laconiajs.io
Cannot recommend Laconia enough, its really well made
We only have a few e2e tests though, I think some of our services are a bit small and the boundaries are not that easy to test. I think we might have some refactoring to do
t
laconia looks interesting
m
https://thebenforce.com/post/cdk-integration-testing is worth the read for anybody interested in async testing.
m
@Thomas Ankcorn I have an example here -> https://github.com/michael-wolfenden/sst-integration-testing The readme also includes additional resources relating to testing
t
This is really cool, thanks Michael!