Skip to content

Test Utilities

Hidetaka Okamoto edited this page Jun 24, 2018 · 1 revision

getHandlerInput

Helper function to make unit tests for intent handler function.

const { DefaultHandlerAdapter, ResponseFactory }  = require('ask-sdk-core')
const assert = require('power-assert')
const { getHandlerInput } = require('ask-utils')
const { HelpIntentHandler } = require('../PATH/TO/YOUR/LAMBDA_JS')

describe('example mocha test', () => {
  it('easy create handlerInput param', async() => {
    const event = {
      context: {...},
      request: {...}
    }
    const handlerAdapter = new DefaultHandlerAdapter()
    const handlerInput = getHandlerInput(event)
    const response = await handlerAdapter.execute(handlerInput, HelpIntentHandler)
    assert.equal(response.outputSpeech.ssml, "<speak>You can say hello to me!</speak>")
  })
})