watson-assistant-test
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

watson-assistant-test

Version License: ISC Coverage Status Node.js CI

Runs automated testing on Watson Assistant Skill.

Install

npm install -g watson-assistant-test

Usage

const AssistantTestSuite = require('watson-assistant-test')

let testSuite = new AssistantTestSuite({
    url: 'YOUR_ASSISTANT_URL',
    workspaceId: 'YOUR_ASSISTANT_WORKSPACE_ID', // Alternatively, provide the assistantId field to use the v2 API
    apikey: 'YOUR_ASSISTANT_API_KEY',
    version: '2021-01-01',
    tests: [
        {
            name: 'Greet and say goodbye',
            rounds: [
                { inputExpression: '{ input: { text: "Hello" } }', evaluateExpression: 'output.text[0] == "Hi! How can I help you?"' },
                { inputExpression: '{ input: { text: "Goodbye" }, context: context }', evaluateExpression: 'output.text[0] == "Bye bye!"' },
            ]
        },
        {
            name: 'Book a visit',
            rounds: [
                { inputExpression: '{ input: { text: "Hello" } }', evaluateExpression: 'output.text[0] == "Hi! How can I help you?"' },
                { inputExpression: '{ input: { text: "Book a visit" }, context: context }', evaluateExpression: 'output.text[0] == "When do you want to pay us a visit?"' },
                { inputExpression: '{ input: { text: "Tomorrow" }, context: context }', evaluateExpression: 'output.text[0] == "All done!"' },
            ]
        },
    ]
})

let results = await testSuite.run()

Sample results

{
  "success": false,
  "passed": 1,
  "failed": 1,
  "details": [
    {
      "name": "Greet and say goodbye",
      "success": true,
    }, 
    {
      "name": "Book a visit",
      "success": false,
      "error": "Expression [output.text[0] == \"All done!\"] is false for obtained output { \"output\":{...}, context: {...} }"
    }
  ]
}

Run tests

npm run test

Author

👤 Marco Cardoso

Show your support

Give a ⭐️ if this project helped you!

Package Sidebar

Install

npm i watson-assistant-test

Weekly Downloads

2

Version

1.4.0

License

ISC

Unpacked Size

8.32 kB

Total Files

8

Last publish

Collaborators

  • macardoso95