gudwin / botbuilder-unit Goto Github PK
View Code? Open in Web Editor NEWLibrary for Microsoft Bot Framework Chatbot unit testing
License: GNU Lesser General Public License v3.0
Library for Microsoft Bot Framework Chatbot unit testing
License: GNU Lesser General Public License v3.0
Hello,
Is it possible to add some steps to test the backchannel events documented there: https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-backchannel?view=azure-bot-service-3.0
Thanks
Hello,
I am looking at timmy.js where I see in order to test conversation flow mentioned in script array a new dialog '/' has been defined. I was wondering what if I need to test my dialog from my Bot app.
Ex: I have following dialog which triggers by LUIS intent help/
bot.dialog('Help', function (session) {
session.send("Hello, I can help you to reserve a meeting room.")
});
session.endDialog();
}).triggerAction({
matches: 'Help'
});
I don't want re-write this dialog as shows in timmy.js.
Would be nice to have regex support in dialog configurations, like:
let script = [
{
"user": "hi"
},
{
"bot": "/hi|welcome/"
}
];
Would match hi
or welcome
as valid response.
Example
const unit = require("botbuilder-unit");
const botbuilder = require("botbuilder");
const script = [];
class TestDialog extends botbuilder.SimpleDialog {
constructor() {
super(() => { });
}
}
const dialog = new TestDialog();
unit(dialog, script, {
title: 'Your first test script',
reporter: new unit.BeautyLogReporter()
}).then(() => {
console.log('Script passed');
}, (err) => {
console.error(err);
});
Results in :
Error: Unknown type of bot/dialog. Error: {"actions":{}}
Looking at botbuilder-unit.js resolveBot
function:
function resolveBot(bot) {
let isWaterfall = ("function" == typeof bot) || Array.isArray(bot);
if (isWaterfall) {
let dialog = bot;
let connector = new TestConnector();
bot = new builder.UniversalBot(connector);
bot.dialog('/', dialog);
} else if (bot instanceof builder.UniversalBot) {
if ( !bot.connector()) {
bot.connector('console', new TestConnector());
}
} else {
throw new Error(`Unknown type of bot/dialog. Error: ${JSON.stringify(bot)}`);
}
return bot;
}
Could maybe check for instanceof builder.Dialog
, eg:
let isWaterfall = ("function" == typeof bot) || Array.isArray(bot);
let isDialog = bot instanceof builder.Dialog;
if (isWaterfall || isDialog) {
...
Would you consider a pull request?
When we define Bot answers with regular expressions, we don't get clear error reports on test fails.
Following are examples with string
and regex
responses from bot.
Example with string
:
{ "user": "reserve meeting room on Tuesday at 3pm" },
{ "bot": "for how long" }
When it fails, we get clear error message, indicating which statement was not matched.
As following:
Example with regex
;
{ "user": "reserve meeting room on Tuesday at 3pm" },
{ "bot": /^for how long/ }
When it fails with regex answer, we get verbose but not useful report.
As following:
TypeError: msg.split is not a function at BeautyLogReporter.outputMessageBox (/project/node_modules/botbuilder-unit/src/log-reporters/BeautyLogReporter.js:56:19)
at BeautyLogReporter.expectationError (/project/node_modules/botbuilder-unit/src/log-reporters/BeautyLogReporter.js:148:8)
at beforeFunc.then (/project/node_modules/botbuilder-unit/src/messages/BotMessage.js:28:34)
at process._tickCallback (internal/process/next_tick.js:109:7)
The License for this project is GPL which means any project that uses this should be GPL (Copyleft). Is this intended?
I suggest using LGPL which allows using the code without forcing the user to make their code public and make sure that any updates to the botbuilder-unit itself is published under LGPL.
Hi, this package depends on async v1.5.x (so does botbuilder v3). However that async package is not listed in the dependencies and it causes problems with the other package which depend on different versions of the async package. npm installs them to the related package's own folder, forcing this package to use the old version.
I will open a PR related to this and add the async version that the required botbuilder version requires.
People with the wrong version would get:
... async.forEachOfSeries is not a function
at TestConnector.send (... /node_modules/botbuilder-unit/src/TestConnector.js:36:11)
TestConnector.js
requires async
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.