Created
February 14, 2017 01:33
-
-
Save gamell/227c6ce43b6fe21a1a2d2960a8d83079 to your computer and use it in GitHub Desktop.
Example of an Alexa Integration Test with alexa-conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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