Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ config can be set one of 2 ways:
1. creating a bot-tester.json file in the root directory of your project.
2. passing in a config object into the options param, which is the last, when creating a BotTester instance


Passing in the config overrides any default values or values set by bot-tester.json. At the moment, the options are:
```javascript
```typescript
{
defaultAddress: botbuilder.IAddress,
timeout: number // in milliseconds
// each filter returns false for messages that the BotTester should ignore
messageFilters: ((message:IMessage) => boolean)[],
ignoreTypingEvent: boolean,
ignoreEndOfConversationEvent: boolean
}
```
if timeout is defined, then a particular ```runTest()``` call will fail if it does not receive each expected message within the timeout period of time set in the options.

additionally, config can be set by using the config updating options in the build chain, documented below in the example use

For a more in depth view, check out [the Bot Tester Framework Config doc](https://microsoftly.github.io/BotTester/interfaces/_config_.iconfig.html)
# Example Usage
```javascript
Expand Down Expand Up @@ -357,3 +364,67 @@ describe('BotTester', () => {
.runTest();
});
```

# can apply one or more message filters in the BotTester options for messages to ignore
``` javascript
it('can apply one or more message filters in the BotTester options for messages to ignore', () => {
bot.dialog('/', (session) => {
session.send('hello');
session.send('how');
session.send('are');
session.send('you?');
});

const ignoreHowMessage = (message) => !message.text.includes('how');
const ignoreAreMessage = (message) => !message.text.includes('are');

return new BotTester(bot, { messageFilters: [ignoreHowMessage, ignoreAreMessage]})
.sendMessageToBot('intro', 'hello', 'you?')
.runTest();
});
```

# can modify BotTester options
``` javascript
describe('can modifiy options in line in builder chain', () => {
it('add a message filter', () => {
bot.dialog('/', (session) => {
session.send('hello');
session.send('there');
session.send('green');
});

return new BotTester(bot)
.addMessageFilter((msg) => !msg.text.includes('hello'))
.addMessageFilter((msg) => !msg.text.includes('there'))
.sendMessageToBot('hey', 'green')
.runTest();
});

it('change timeout time', (done) => {
const timeout = 750;
bot.dialog('/', (session) => {
setTimeout(() => session.send('hi there'), timeout * 2 );
});

expect(new BotTester(bot)
.setTimeout(timeout)
.sendMessageToBot('hey', 'hi there')
.runTest()
).to.be.rejected.notify(done);
});

it('can ignore typing events', () => {
bot.dialog('/', (session) => {
session.send('hello');
session.sendTyping();
session.send('goodbye');
});

return new BotTester(bot)
.ignoreTypingEvent()
.sendMessageToBot('hey', 'hello', 'goodbye')
.runTest();
});
});
```
2 changes: 1 addition & 1 deletion docs/assets/js/search.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/4638dc4/src/assertionLibraries/ChaiExpectation.ts#L32">assertionLibraries/ChaiExpectation.ts:32</a></li>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/34d027f/src/assertionLibraries/ChaiExpectation.ts#L32">assertionLibraries/ChaiExpectation.ts:32</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -155,7 +155,7 @@ <h3><span class="tsd-flag ts-flagPrivate">Private</span> message</h3>
<div class="tsd-signature tsd-kind-icon">message<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/4638dc4/src/assertionLibraries/ChaiExpectation.ts#L32">assertionLibraries/ChaiExpectation.ts:32</a></li>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/34d027f/src/assertionLibraries/ChaiExpectation.ts#L32">assertionLibraries/ChaiExpectation.ts:32</a></li>
</ul>
</aside>
</section>
Expand All @@ -165,7 +165,7 @@ <h3><span class="tsd-flag ts-flagPrivate">Private</span> subject</h3>
<div class="tsd-signature tsd-kind-icon">subject<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">__type</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/4638dc4/src/assertionLibraries/ChaiExpectation.ts#L31">assertionLibraries/ChaiExpectation.ts:31</a></li>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/34d027f/src/assertionLibraries/ChaiExpectation.ts#L31">assertionLibraries/ChaiExpectation.ts:31</a></li>
</ul>
</aside>
</section>
Expand All @@ -183,7 +183,7 @@ <h3>not<wbr>ToBe<wbr>Empty</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/_assertionlibraries_iexpectation_.iexpectation.html">IExpectation</a>.<a href="../interfaces/_assertionlibraries_iexpectation_.iexpectation.html#nottobeempty">notToBeEmpty</a></p>
<ul>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/4638dc4/src/assertionLibraries/ChaiExpectation.ts#L39">assertionLibraries/ChaiExpectation.ts:39</a></li>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/34d027f/src/assertionLibraries/ChaiExpectation.ts#L39">assertionLibraries/ChaiExpectation.ts:39</a></li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
Expand All @@ -201,7 +201,7 @@ <h3>to<wbr>BeTrue</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/_assertionlibraries_iexpectation_.iexpectation.html">IExpectation</a>.<a href="../interfaces/_assertionlibraries_iexpectation_.iexpectation.html#tobetrue">toBeTrue</a></p>
<ul>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/4638dc4/src/assertionLibraries/ChaiExpectation.ts#L51">assertionLibraries/ChaiExpectation.ts:51</a></li>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/34d027f/src/assertionLibraries/ChaiExpectation.ts#L51">assertionLibraries/ChaiExpectation.ts:51</a></li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
Expand All @@ -219,7 +219,7 @@ <h3>to<wbr>Deeply<wbr>Include</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/_assertionlibraries_iexpectation_.iexpectation.html">IExpectation</a>.<a href="../interfaces/_assertionlibraries_iexpectation_.iexpectation.html#todeeplyinclude">toDeeplyInclude</a></p>
<ul>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/4638dc4/src/assertionLibraries/ChaiExpectation.ts#L61">assertionLibraries/ChaiExpectation.ts:61</a></li>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/34d027f/src/assertionLibraries/ChaiExpectation.ts#L61">assertionLibraries/ChaiExpectation.ts:61</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -252,7 +252,7 @@ <h3>to<wbr>Equal</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/_assertionlibraries_iexpectation_.iexpectation.html">IExpectation</a>.<a href="../interfaces/_assertionlibraries_iexpectation_.iexpectation.html#toequal">toEqual</a></p>
<ul>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/4638dc4/src/assertionLibraries/ChaiExpectation.ts#L43">assertionLibraries/ChaiExpectation.ts:43</a></li>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/34d027f/src/assertionLibraries/ChaiExpectation.ts#L43">assertionLibraries/ChaiExpectation.ts:43</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -276,7 +276,7 @@ <h3>to<wbr>Include</h3>
<aside class="tsd-sources">
<p>Implementation of <a href="../interfaces/_assertionlibraries_iexpectation_.iexpectation.html">IExpectation</a>.<a href="../interfaces/_assertionlibraries_iexpectation_.iexpectation.html#toinclude">toInclude</a></p>
<ul>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/4638dc4/src/assertionLibraries/ChaiExpectation.ts#L47">assertionLibraries/ChaiExpectation.ts:47</a></li>
<li>Defined in <a href="https://github.com/microsoftly/BotTester/blob/34d027f/src/assertionLibraries/ChaiExpectation.ts#L47">assertionLibraries/ChaiExpectation.ts:47</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand Down Expand Up @@ -330,6 +330,9 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</spa
<li class=" tsd-kind-external-module tsd-is-external">
<a href="../modules/_assertionlibraries_iexpectation_.html">"assertion<wbr>Libraries/IExpectation"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="../modules/_builtinmessagefilters_.html">"built<wbr>InMessage<wbr>Filters"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="../modules/_config_.html">"config"</a>
</li>
Expand Down
Loading