I am trying to add unit tests to one of my services. The problem i encountered is with using jest-dynamodb package (which is the jest goto solution in this case AFAIK).
To my understanding the package should run dynamod-local under the hood. But it seems like I have to manually start a local instance of dynamo for the tests that try to interact with dynamo to pass.
specifically, If i don’t start the local dynamo instance my tests exceed the default timeout of 5 seconds. if i elongate the timeout i get the following error:
UnknownEndpoint: Inaccessible host: 'localhost'. This service may not be available in the 'local-env' region.
I guess something in my configuration is wrong, but can’t seem to figure out exactly what it is. Any advise would be appreciated.
I’d also love to hear how others are testing dynamodb interactions.
Sorry to revive a dead forum thread. I am experiencing the exact same issue and would like to know if you managed to solve it, and if so what your solution was.
Hi
Sadly, no. I put some time trying to figure this out but didn’t get anywhere so I dropped it and ran these tests by starting the local instance myself.
This is one of the quirks that made me opt for running integration tests against live resources in the cloud and keep local testing for unit tests and local lambda invocations only.
If you ever solve this, I’d love to hear what you did.
In the end, I ended up just switching from the jest-dynamodb package to the jest-dynalite package. Using the jest-dynalite package is very similar to using the jest-dynamodb package, so it was very easy to transition. In the end, the dynalite package “just worked” and I had very little trouble with it, and will use it when unit testing projects which interact with DynamoDB from now on.