Skip to content

Instantly share code, notes, and snippets.

@microsoftly
Last active August 28, 2017 23:45
Show Gist options
  • Save microsoftly/607c0529c204467801dd6fad8d5c7a83 to your computer and use it in GitHub Desktop.
Save microsoftly/607c0529c204467801dd6fad8d5c7a83 to your computer and use it in GitHub Desktop.
The BotTester framework can inspect session state
const { BotTester } = require('bot-tester');
const { expect } = require('chai');
describe('Bot Tester', () => {
it('can inspect session state', () => {
bot.dialog('/', [(session) => {
new Prompts.text(session, 'What would you like to set data to?');
}, (session, results) => {
session.userData = { data: results.response };
session.save();
}]);
return new BotTester(bot)
.sendMessageToBot('Start this thing!', 'What would you like to set data to?')
.sendMessageToBotAndExpectSaveWithNoResponse('This is data!')
.checkSession((session) => {
expect(session.userData).not.to.be.null;
expect(session.userData.data).to.be.equal('This is data!');
})
.runTest();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment