Class: TestParser

TestParser(fileName)

Represents the parser used for converting a yaml file into a test suite

Constructor

new TestParser(fileName)

Parameters:
Name Type Description
fileName string the yaml file that will be parsed
Source:

Methods

addQuotesToNonRegexString(origin) → {string}

Add quotes to string if not a regex
Parameters:
Name Type Description
origin string original string
Source:
Returns:
string with quotes
Type
string

findReplace(script) → {string}

Replaces constants set in the configuration which the actual values
Parameters:
Name Type Description
script string the yaml file as a string
Source:
Returns:
Type
string

getDefinedVariables(assertion) → {Array.<string>}

Gets the different variables that needs to be replaced
Parameters:
Name Type Description
assertion string the yaml file as a string
Source:
Returns:
the defined variables
Type
Array.<string>

getOperator(assertionString, isUtteranceIncluded) → {string}

returns the operator used inside the assertion
Parameters:
Name Type Description
assertionString string the assertion as a string
isUtteranceIncluded boolean if isUtteranceIncluded is set to true, the first part of the string will be considered as an utterance
Source:
Returns:
Type
string

load(contents)

Set the contents of the YML file
Parameters:
Name Type Description
contents object set the contents of the file
Source:

loadYamlObject(yamlObject)

loads a yaml object into a yaml file
Parameters:
Name Type Description
yamlObject object yaml representation of a yaml file
Source:

parse(configurationOverride) → {TestSuite}

Parses a test file and returns a test suite
Parameters:
Name Type Description
configurationOverride string configuration override for the test suite
Source:
Returns:
Type
TestSuite

parseInteraction(test, interactionJSON, index) → {TestInteraction}

Parse a single interaction
Parameters:
Name Type Description
test Test the Test the contains the interaction being parsed
interactionJSON object | string the interaction being parsed
index number the index of the interaction in the test
Source:
Returns:
Type
TestInteraction

parseObjectAssertion(interaction, element) → {Assertions}

Parses a single Assertion inside an interaction
Parameters:
Name Type Description
interaction TestInteraction the interaction where this assertion is used
element object the object representation of the YAML element
Source:
Returns:
Type
Assertions

parseStringAssertion(interaction, assertionString, isUtteranceIncluded) → {Assertion}

Parse a string into assertion object. Our short syntax is not valid in YAML. We look for an operator inside the string Examples: Hi exit LaunchRequest != hi cardTitle != hi cardTitle != - Value1 - Value2 - Value2
Parameters:
Name Type Default Description
interaction TestInteraction the interaction that includes this assertion
assertionString string the assertion as a string
isUtteranceIncluded boolean false if isUtteranceIncluded is set to true, the first part of the string will will be considered as an utterance
Source:
Returns:
Type
Assertion

parseTest(suite, rawTest, testIndex) → {Test}

Parses a single test of the yaml test file
Parameters:
Name Type Description
suite TestSuite the complete test suite
rawTest object a single raw test from the yaml file
testIndex number the index of which test we are parsing
Source:
Returns:
Type
Test

parseTests(suite, rawTests) → {Array.<Test>}

Parses the tests section of the yaml test file
Parameters:
Name Type Description
suite TestSuite the complete test suite
rawTests object the raw tests from the yaml file
Source:
Returns:
Type
Array.<Test>

validateIvrTests(suite)

validate if ivr test are valid, this method should be called after global configuration is load
Parameters:
Name Type Description
suite testSuite test suite will all the tests
Source: