rmtuckerphx / alexa-skill-serverless-starter-template

An Alexa Skill starter project template that uses the Serverless Framework and the Alexa Skills Kit SDK for Node.js
MIT License
81 stars 11 forks source link

End-to-end tests has errors #2

Open rmtuckerphx opened 7 years ago

rmtuckerphx commented 7 years ago

The e2e tests should each be running independently of previous runs but it doesn't appear that is the case.

timrwilliams commented 7 years ago

I don't have a solution to this yet but I think this is caused by the Alexa Skills Kit automatically persisting and retrieving session attributes to DynamoDB. Assuming your application checks and sets some kind of user state when handling a request (e.g. this.attributes['lastfact'] = 2) this state will still be in place for the next test as the Skills Kit will automatically retrieve it prior to invoking your handler.

Possible solutions I've considered are:

  1. Run each test with a new user record, e.g. testaccount-{GUID} (this will lead to a large buildup of user records so need a way of automatically cleaning these records up)
  2. Call DynamoDB directly to delete the user record after the test
  3. Mock DynamoDB so no state is retained

I've not found a clean way to access the DynamoDB table in the test suite to implement any of these solutions yet so any suggestions welcome.