BrianMacIntosh/alexa-skill-test-framework

Assert specific strings inside outputSpeech and reprompt

Closed this issue · 3 comments

It would be really cool to assert certain words or phrases inside the output and reprompt speech instead of matching the whole string.

i think you can do that using the saysCallback

Yep, you can do that. I could see making it part of the API to make it less verbose, though - or providing a method to generate that callback for you.

i've been doing this lately

const expect = require('chai').expect;

function assertReply(expectedReply) {
  return (context, speech) => {
    expect(speech).to.equal(`<speak>${expectedReply}</speak>`);
  };
}

{ request: alexaTest.getIntentRequest('AMAZON.YesIntent'), shouldEndSession: false, saysCallback: assertReply('Great!') },