4.22.2 • Published 19 days ago

botbuilder-testing v4.22.2

Weekly downloads
2,013
License
MIT
Repository
github
Last release
19 days ago

Bot Framework Testing Utilities

This library contains some helper classes useful for testing bots built with Bot Framework.

Install

First, install this library from npm:

npm install --save botbuilder-testing

Unit Tests for Dialogs

DialogTestClient provides a mechanism for testing dialogs outside of a bot, and without having to set up a working adapter. This class can be used to write unit tests for dialogs that test responses on a step-by-step basis. Any dialog built with botbuilder-dialogs should work.

Use the DialogTestClient to drive unit tests of your dialogs.

To create a test client:

const client = new DialogTestClient('test', dialog_to_test, dialog_options, OptionalMiddlewares);

To "send messages" through the dialog:

let reply = await client.sendActivity('test');

To check for additional messages:

reply = client.getNextReply();

Here is a sample unit test using assert:

const { DialogTestClient, DialogTestLogger } = require('botbuilder-testing');
const assert = require('assert');

const my_dialog = new SomeDialog();
const options = { ... dialog options ... };

// set up a test client with a logger middleware that logs messages in and out
const client = new DialogTestClient('test', my_dialog, options, [new DialogTestLogger()]);

// send a test message, catch the reply
let reply = await client.sendActivity('hello');
assert.strictEqual(reply.text, 'hello yourself', 'first message was wrong');
// expecting 2 messages in a row?
reply = client.getNextReply();
assert.strictEqual(reply.text, 'second message', 'second message as wrong');

// test end state
assert.strictEqual(client.dialogTurnResult.status, 'empty', 'dialog is not empty');

Additional examples are available here

DialogTestLogger

This additional helper class will cause the messages in your dialog to be logged to the console. By default, the transcript will be logged with the mocha-logger package. You may also provide your own logger:

const testlogger = new DialogTestLogger(console);
4.22.2

19 days ago

4.17.0-spike1

1 month ago

4.17.0-dev1

2 months ago

4.22.2-rc2

2 months ago

4.14.1-dev8

2 months ago

4.22.1

3 months ago

4.22.2-rc1

3 months ago

4.21.5-rc

3 months ago

4.22.0

3 months ago

4.14.1-dev7

3 months ago

4.14.1-dev6

4 months ago

4.21.4

4 months ago

4.14.1-dev5

4 months ago

4.21.4-rc2

4 months ago

4.21.4-rc

5 months ago

4.14.1-dev4

5 months ago

4.21.4-dev2

5 months ago

4.14.1-dev3

5 months ago

4.21.4-dev

5 months ago

4.21.3-rc

5 months ago

4.21.3

5 months ago

4.21.1

6 months ago

4.21.2

5 months ago

4.21.0

6 months ago

4.20.2

6 months ago

4.20.3

6 months ago

4.20.1

8 months ago

4.20.1-rc

8 months ago

4.21.1-rc2

6 months ago

4.14.1-dev1

6 months ago

4.14.1-dev2

6 months ago

4.21.1-rc

6 months ago

4.20.0-rc

11 months ago

4.20.0

11 months ago

4.19.3-rc

1 year ago

4.19.3-rc2

1 year ago

4.19.3-rc4

1 year ago

4.19.3-rc5

1 year ago

4.19.1-rc1

1 year ago

4.19.1

1 year ago

4.19.2

1 year ago

4.19.3

1 year ago

4.19.1-rc

1 year ago

4.19.0-rc

1 year ago

4.19.0

1 year ago

4.18.0-rc0

2 years ago

4.18.0

2 years ago

4.17.1-rc0-rc

2 years ago

4.17.1

2 years ago

4.17.0-rc

2 years ago

4.17.0

2 years ago

4.16.0

2 years ago

4.15.0

2 years ago

4.15.0-rc1

2 years ago

4.15.0-rc3

2 years ago

4.15.0-rc2

2 years ago

4.15.0-rc0

3 years ago

4.14.1

3 years ago

4.14.0

3 years ago

4.14.0-rc2

3 years ago

4.14.0-rc1

3 years ago

4.14.0-rc0

3 years ago

4.10.6-rc0

3 years ago

4.9.5

3 years ago

4.9.5-rc0

3 years ago

4.9.5-rc1

3 years ago

4.13.6

3 years ago

4.11.2-rc0

3 years ago

4.12.1-rc0

3 years ago

4.13.6-rc0

3 years ago

4.10.6

3 years ago

4.12.1

3 years ago

4.11.2

3 years ago

4.13.5

3 years ago

4.13.4

3 years ago

4.13.3

3 years ago

4.13.2

3 years ago

4.13.1

3 years ago

4.13.0-rc9

3 years ago

4.13.0

3 years ago

4.13.0-rc8

3 years ago

4.13.0-rc7

3 years ago

4.13.0-rc6

3 years ago

4.13.0-rc5

3 years ago

4.13.0-rc4

3 years ago

4.13.0-rc3

3 years ago

4.13.0-rc2

3 years ago

4.14.0-dev

3 years ago

4.13.0-rc0

3 years ago

4.13.0-rc1

3 years ago

4.12.0

3 years ago

4.12.0-rc4

3 years ago

4.12.0-rc3

3 years ago

4.12.0-rc2

3 years ago

4.12.0-rc1

3 years ago

4.12.0-rc0

3 years ago

4.11.1

3 years ago

4.10.5

3 years ago

4.9.4

3 years ago

4.8.1

3 years ago

4.7.3

3 years ago

4.11.1-rc0

3 years ago

4.11.0

3 years ago

4.11.0-rc3

4 years ago

4.11.0-rc2

4 years ago

4.11.0-rc1

4 years ago

4.11.0-rc0

4 years ago

4.10.4

4 years ago

4.10.3

4 years ago

4.10.2-rc0

4 years ago

4.10.1

4 years ago

4.10.0

4 years ago

4.10.0-rc1

4 years ago

4.10.0-rc0

4 years ago

4.9.3

4 years ago

4.9.2

4 years ago

4.9.1

4 years ago

4.9.0

4 years ago

4.8.0

4 years ago

4.7.2

4 years ago

4.7.1

4 years ago

4.7.0

4 years ago

4.6.2

4 years ago

4.6.1

4 years ago

4.6.0

5 years ago

4.6.0-preview1

5 years ago

4.5.3

5 years ago

4.5.2

5 years ago

4.5.1

5 years ago

4.5.0

5 years ago