Skip to content

Instantly share code, notes, and snippets.

@gamell
Created February 14, 2017 01:33
Show Gist options
  • Save gamell/227c6ce43b6fe21a1a2d2960a8d83079 to your computer and use it in GitHub Desktop.
Save gamell/227c6ce43b6fe21a1a2d2960a8d83079 to your computer and use it in GitHub Desktop.
Example of an Alexa Integration Test with alexa-conversation
const conversation = require('alexa-conversation');
// your Alexa skill main file. app.handle needs to exist
const app = require('../../index.js');
// those will be used to generate the requests to your skill
const opts = {
name: 'Test Conversation',
app: app,
appId: 'your-app-id'
};
// Other optional parameters are available. See readme.md
// initialize the conversation
conversation(opts)
.userSays('LaunchIntent') // trigger the first Intent
.plainResponse // this gives you access to the non-ssml response
// asserts that response and reprompt are equal to the given text
.shouldEqual('Welcome back', 'This is the reprompt')
// assert not Equals
.shouldNotEqual('Wrong answer', 'Wrong reprompt')
// assert that repsonse contains the text
.shouldContain('Welcome')
// assert that the response matches the given Regular Expression
.shouldMatch(/Welcome(.*)back/)
// fuzzy match, not recommended for production use. See readme.md for more details
.shouldApproximate('This is an approximate match')
.userSays('IntentWhichRequiresSlots', {slotOne: 'slotValue'}) // next interaction, this time with a slot.
.ssmlResponse // access the SSML response
.shouldMatch(/<say>(Hello|Bye)</say>/)
.shouldNotMatch(/<say>Wrong answer</say>/)
.end(); // this will actually run the conversation defined above
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment