-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Conversation
By the way, I don't think |
I got it running through lerna. I added the People can now add coverage when fixing issues on the dialog engine, which I believe is a great enhancement. |
Can you add some documentation for how this code can be leveraged to write tests of a bot? |
@ianfixes Check the packages/botkit/tests/Dialog.tests.js file, that is the starting point. Actually, this addition allows a much better test coverage of the Botkit project itself in the future since it makes dialog testing possible in isolation. |
In this example: it('should follow a dialog', async function () {
const introDialog = new BotkitConversation('introduction', bot);
introDialog.ask({
text: 'You can say Ok',
quick_replies: [{
title: 'Ok',
payload: 'Ok'
}],
}, [], 'continue');
bot.addDialog(introDialog);
// set up a test client
const client = new BotkitTestClient('test', bot, 'introduction');
// Get details for the reply
const quickreply_reply = await client.sendActivity();
assert(quickreply_reply.text === 'You can say Ok');
assert(quickreply_reply.channelData.quick_replies[0].title === 'Ok');
}); It looks like you're creating the bot immediately before testing it. In normal use, I'd be instantiating my own bot-under-test somehow, and the test would simply have a-priori knowledge that there was a skill called |
@ianfixes Yes. The test I wrote is "self-contained" as an example. The dialog should not be known to the test, other than its name ( |
Thank you for doing this work. I'll work to get it included in the next release. |
This is super awesome, btw. I am using this testing tool to validate the 4.6 changes. Hooray! |
Hello! Our team is starting to love the library you are developing. Since we are starting to consider writing tests to make sure our botkit bots are behaving as expected.
Since we could not find a specific way to test the library, I went ahead and searched around the web for a way to test botbuilder bots. Microsoft seems to provide a way to do it: https://github.com/microsoft/botbuilder-js/blob/master/libraries/botbuilder-testing/src/dialogTestClient.ts
So I went ahead and brought that code back into Botkit's code base and adapted it to take a Botkit instance and a thread name to test. I have provided an example test file showing how to use the test client in the PR.
This will be immensely useful for both our team and the whole botkit community.