Retrieve Botium error message for IntentAsserter as a Json for mocha reporting

52 Views Asked by At

When intent assertion fails, Botium returns a verbose error message that is good for console logging or general reporting. However, I need to run some post processing to analyze what intents were triggered and what were expected.

Here is an example of the verbose message:

Error: INTENT_NAME/INTENT_NAME_input-L2/Line 6: assertion error - Line 6: Expected intent "INTENT_NAME" but found nothing

#

ASSERTION FAILED in IntentAsserter - Expected: "INTENT_NAME" - Actual: empty

INPUT: What is your name?

{"type":"asserter","source":"IntentAsserter","context":{"params":{"args":["INTENT_NAME"]}},"cause":{"expected":"INTENT_NAME","actual":null},"message":"INTENT_NAME/INTENT_NAME_input-L2/Line 6: assertion error - Line 6: Expected intent \" INTENT_NAME\" but found nothing","input":{"sender":"me","channel":null,"messageText":"What is your name?","stepTag":"Line 3","not":false,"asserters":[],"logicHooks":[],"userInputs":[]}}

If I could retrieve just the json in the example above, it would satisfy my requirement.

1

There are 1 best solutions below

3
On

I did some digging around with mocha and found the answer.

https://mochajs.org/api/tutorial-custom-reporter.html

The mocha event listener EVENT_TEST_FAIL passes the error object to the callback that has all the details.

Cheers.