Giter Site home page Giter Site logo

gudwin / botbuilder-unit Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 7.0 369 KB

Library for Microsoft Bot Framework Chatbot unit testing

License: GNU Lesser General Public License v3.0

JavaScript 100.00%
bot chatbot-testing microsoft-bot-framework tdd-framework

botbuilder-unit's People

Contributors

gudwin avatar user1m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

botbuilder-unit's Issues

How to test my own dialogs in botbuilder-unit?

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.

regex support in dialogs array

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.

Unknown type of bot/dialog error when extending botbuilder dialog classes

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?

Error reports for RegularExpression mismatches are not clear

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:
2017-12-12-121238_1366x768_scrot


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:
2017-12-12-121612_1366x768_scrot

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)

License

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.

Used package is not listed as a dependency

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.