Darvin Testing Framework
A framework for testing Darvin.ai chatbots on nodejs with jasmine.
Usage
-
Install
npm install darvin-testing-framework
-
Require darvin-testing-framework
in a javascript file which will be executed by jasmine.
Click here for more info about jasmine test execution.
const DarvinTestingFramework = require('darvin-testing-framework');
const darvin = new DarvinTestingFramework();
-
Instruct the Darvin Testing Framework to define BDD specifications for your bot based on a declarative specification that you provide.
const accountantBotSpec = require('./accountant-bot.spec.json');
const appointmentsBotSpec = require('./appointments-bot.spec.json');
darvin.describe(accountantBotSpec);
darvin.describe(appointmentsBotSpec);
JSON chatbot specifications format
The JSON specification must have the following properties:
name
- This is the name of your chatbot. It will be used as a name for its own test suitebotId
- The Id of the chatbot that is being testedchannel
- An object that contains communication details of the target chatbot
id
- Id of the system communication channel of the target chatbottoken
- Verification token of the system communication channel of the target chatbot
scenarios
- an array of scenarios describing the chatbot's behavior
it
- follows the idea of behavior-driven development and serves as the first word in the test name, which should be a complete sentencesteps
- sequence (array) of steps defining the scenario
user
- what the user says as a single message
text
- text of the message
bot
- what is the expected answer from the bot as an array of optional behavior. Each element is an array of messages. The step is considered valid if any sequence of messages matches the actual chatbot response
text
- text of a single messagequickReplies
- array of quick reply options
Example spec
The following example spec verifies that the Sample bot introduces itself and enters into a conversation
.
{
"name": "Sample bot",
"botId": "[your bot id]",
"channel": {
"id": "[id of the system channel]",
"token": "[verification token]"
},
"scenarios": [
{
"it": "introduces itself and enters into a conversation",
"steps": [
{
"user": { "text": "hi" },
"bot": [
[
{
"text": "This is a getting started conversation for your chatbot.",
"quickReplies": ["Conversation 1", "Conversation 2"]
}
]
]
},
{
"user": { "text": "Conversation 1" },
"bot": [
[
{
"text": "This is conversation 1"
}
]
]
}
]
}
]
}
Our QuickStart sample has specifications with it. Feel free to explore it in order to get more familiar with the format. Click here to get it. It only has scenarios
since it is a general specification and it is not targeted at a specific chatbot isntance.