MockConversation

Testing. MockConversation

Extension for the main Conversation class with testing conveniences.

Constructor

new MockConversation()

Source:
Example
const Testing = require('@oracle/bots-node-sdk/testing');
const { MyCustomComponent } = require('path/to/custom/components');

describe('MyCustomComponent', () => {
  it('should reply with message', done => {
    const request = Testing.MockRequest();
    const conversation = Testing.MockConversation.fromRequest(request);
    new MyCustomComponent()
      .invoke(conversation, err => {
        expect(conversation.response().messages).toBeDefined();
        return err ? done.fail(err) : done();
      });
  })
})

Methods

getReplies()

Description:
  • get conversation reply messages
Source:
Returns:
- message list returned by the component

(static) any()

Description:
  • create a mock conversation with an "empty" valid request.
Source:
Returns:
Conversation

(static) fromRequest(req)

Description:
  • create conversation instance from a request
Source:
Parameters:
Name Type Description
req * the component invocation request body
Returns:
Conversation