Constructor
new Assertions(interaction, path, operator, value, variables, originalOperator)
Parameters:
Name | Type | Description |
---|---|---|
interaction |
TestInteraction | the interaction that is being evaluated |
path |
string | the Json path of the property in the response being evaluated |
operator |
string | the operator used to evaluate the response property |
value |
string | the value that is evaluated against the response property |
variables |
Array.<string> | variables inside the utterance that can be replaced |
originalOperator |
string | the operator before parsing the interaction |
- Source:
Members
exit
Returns true if this assertion includes an exit
- Source:
goto
Returns true if this assertion includes a go to
- Source:
interaction
Returns the interaction that contains this assertion
- Source:
lineNumber
Returns in which line number this assertion is located
- Source:
operator
Returns what is the operator that we are using to evaluate the response
- Source:
originalOperator
Returns the operator before parsing the interaction
- Source:
path
Returns what is the Json path that we are evaluating in the response
- Source:
value
Returns what is the value against we are evaluating
- Source:
variables
Returns a list of variables to replace in the assertion
- Source:
variables
Gets the list of variables to replace in the assertion
- Source:
Methods
evaluate(response) → {boolean}
Evaluates this assertion against the provided response and returns true if it succeeds
Parameters:
Name | Type | Description |
---|---|---|
response |
object | the response to which we do the assertion |
- Source:
Returns:
- Type
- boolean
evaluateRegex(expectedValue, actualValue, ignoreCase) → {boolean}
Evaluates if the actual value matches the expected value regex
Parameters:
Name | Type | Description |
---|---|---|
expectedValue |
string | expected value regex defined in the assertion |
actualValue |
string | Actual value returning in the response |
ignoreCase |
boolean | ignore case when evaluating the strings |
- Source:
Returns:
- Type
- boolean
evaluateRegexOrString(operator, expectedValue, actualValue, ignoreCase) → {boolean}
Evaluates if a regex or string complies with the assertion
Parameters:
Name | Type | Description |
---|---|---|
operator |
string | Operator used to evaluate the expected value against the actual one. |
expectedValue |
string | Value defined in the assertion |
actualValue |
string | Actual value returning in the response |
ignoreCase |
boolean | ignore case when evaluating the strings |
- Source:
Returns:
- Type
- boolean
evaluateString(expectedValue, actualValue, ignoreCase) → {boolean}
Evaluates if the actual value contains the expected value
Parameters:
Name | Type | Description |
---|---|---|
expectedValue |
string | Value defined in the assertion |
actualValue |
string | Actual value returning in the response |
ignoreCase |
boolean | ignore case when evaluating the strings |
- Source:
Returns:
- Type
- boolean
isRegex(expectedValue) → {boolean}
Validates if the expected value is a regex
Parameters:
Name | Type | Description |
---|---|---|
expectedValue |
string | a string expected value |
- Source:
Returns:
- Type
- boolean
parse()
Parses the value to check and set the goto property if needed
- Source:
toString(json, errorOnResponse) → {string}
Returns the assertion evaluation in a string with the error details if the assertion has failed
Parameters:
Name | Type | Description |
---|---|---|
json |
object | the response being evaluated |
errorOnResponse |
string | error that was generated, if present this is what we would return |
- Source:
Returns:
- Type
- string
toYamlObject() → {object}
Returns the assertion part of a yaml object
{ action: string, operator: string, value: string|string[]}
- Source:
Returns:
- Type
- object
validate()
Validate if the assertion syntax is correct if not throws a Parser Error
- Source:
Throws:
valueAtPath(json) → {string}
Returns what is in the value in the response for the Json path
Parameters:
Name | Type | Description |
---|---|---|
json |
object | the response being evaluated |
- Source:
Returns:
- Type
- string