npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

botbuilder-wolf-rive

v1.1.2

Published

Rivescript Testing for Wolf Bots

Downloads

10

Readme

Botbuilder Wolf Rive

As you build out your abilities with Botbuilder Wolf, you'd want to test out your bot in an easy way.

Now you can!

With Wolf Rive, you can write readable test using Rivescript in one or multiple .rive files.

How to use

1. Install:

npm install --save-dev botbuilder-wolf-rive jest

2. Build your Rivescript Test File:

Note: Rivescript syntax is very easy to write
> topic is the start of a test conversation flow (Rivescript terminology: "topic").
+ is the start of a user utterance (Rivescript term: "trigger").
- is the start of a bot response. Bot can have multiple responses. ^ is the start of a new line for the bot response

If you're using vscode, you can install the rivescript extension for language support.

Here is an example of three test flows:

> topic greet
+ hi, my name is Hao
- Hello Hao! // this is a comment that will not be in the test

> topic add_pizza
+ i want a large pizza
- what toppings would you like on it?

+ extra cheese
- a large extra cheese pizza coming right up!

> topic add_pizza_then_show_order
+ i want a large pizza
- what toppings would you like on it?

+ extra cheese
- a large extra cheese pizza coming right up!

+ what did i order?
- this is what you ordered
^ a large extra cheese pizza

3. Create your Test Behind the scenes, this test library is using Jest to run the tests. And it needs to know a little more about your wolf configuration.

Create a new test files with the following code:

/* global describe, test, expect */
import { parseRive, runWolfTests, createWolfRunner } from 'botbuilder-wolf-rive'
import abilities from '../abilities' // your abilities
import nlpWolf from '../nlp' // your nlp function

const wolfRunner = createWolfRunner(
  nlpWolf,
  () => abilities,
  'greet'
)

const demo = parseRive('./src/tests/demo.rive') // <=== Notice CWD is from the project root
// const sprint1 = parseRive('./src/tests/sprint1.rive')
// const sprint2 ...

describe('Demo Stage', () => {
  runWolfTests(demo, wolfRunner)
})

Both the nlp and ability functions can be async functions, however it will dramatically increase test duration if NLP is async.

Save this file in src/tests/bot.test.js (or .ts)

4. Run your Test Replace the value of scripts -> test in your package.json like so:

{
  /* ... */
  "scripts": {
    "test": "jest src/tests/bot.test"
  }
}

And run npm test will give you this: test output for pizza test

FAQ:

  • Why did you make this library?

Testing is important, but testing a bot is not fun. There seem to be a gap between unit testing every method of a bot and a full E2E test suite that requires the botbuilder.

This library aims to fill that gap for you. It does not touch the bot context, and only test the wolf ability logic which takes in the user utterance and tests the messageStringArray property from wolf's outtake result.

  • How does the tests work?

Each "topic" is a test conversation flow. The topic name should be snake cased.

The topic name should also be descriptive to what the flow is about, because this name is shown on the test report.

Each topic is run on a fresh conversationState, meaning one test conversation flow will not interfere or influence another flow.

  • Why did you use Rivescript?

It has an easy-to-learn syntax that anyone can write. I recognize that we are repurposing Rivescript a bit to use it as a testing tool, but isn't "repurposing to make lives better" what engineering is all about? :wink:

  • Hey wolf-rive does not support feature X of Rivescript

This library is simply for testing. It is not meant to replace wolf, or botbuilder for that matter. Therefore, it currently does not support things like Rivescript's variables or topic inheritance.