serverless-appsync-plugin icon indicating copy to clipboard operation
serverless-appsync-plugin copied to clipboard

Unit test support for appsync dynamodb resolvers

Open neerajg5 opened this issue 4 years ago • 1 comments

Hi, I've recently started by journey on appsync service. So wondering if there is any support for writing unit test cases (using javascript based framework) for dynamodb resolvers.

I've looked at the link https://www.npmjs.com/package/serverless-appsync-simulator . However, it seems the link is for simulation and not for unit test cases. Please guide.

neerajg5 avatar Apr 08 '20 18:04 neerajg5

@neerajg5 Usually, dynamodb/database operations are mocked in test environments (jest, mocha). As you said, the simulator is only a simulator for local testing. It is not meant for automated testing. This plugin is meant for deploying, not testing either.

It is hard to really write unit tests for this. First of all because there is no way to guarantee a full and accurate reproduction of what happens in AWS once deployed.

If you really want to automate testing this I guess the only way for now would be to deploy a test stack in AWS and have the tests call the endpoints directly.

Alternatively you could also do that with the simulator (instead of a deployed stack). The advantage would be that you wouldn't need to deploy a real stack, which should be faster. A con would be that the simulator night not reflect a real stack 100% of the time and some bugs might go through.

Hope that helps

bboure avatar Apr 21 '20 07:04 bboure