@samatawy/rules
    Preparing search index...

    Class TestSuite

    A TestSuite is a collection of test cases that can be run together to validate the behavior of the rules engine. You can create one TestSuite per workspace.

    Index

    Constructors

    Methods

    • Add a test case to the suite. The test case can be provided either as a string in the DSL syntax or as an instance of AbstractTestCase. If a string is provided, it will be parsed into an AbstractTestCase using the TestParser.

      Parameters

      • testCase: string | AbstractTestCase

        The test case to add, either as a string in DSL syntax or an instance of AbstractTestCase.

      Returns AbstractTestCase

      The added test case as an instance of AbstractTestCase.

    • Remove a test case from the suite by its name. If multiple test cases have the same name, they will all be removed.

      Parameters

      • testCase: string | AbstractTestCase

        The name or instance of the test case to remove.

      Returns void

    • Clear all test cases from the suite, leaving it empty. This can be useful for resetting the suite or removing all test cases at once.

      Returns void

    • Get all test cases in the suite. This returns an array of AbstractTestCase instances representing all the test cases currently in the suite.

      Returns AbstractTestCase[]

      An array of AbstractTestCase instances for all test cases in the suite.

    • Get test cases that require a specific input path or paths. If more than one input path is provided, it will return test cases that require all of the specified paths.

      Parameters

      • inputPath: string | string[]

        The input path or paths to check for in the required set of each test case.

      Returns AbstractTestCase[]

      An array of AbstractTestCase instances that require the specified input path(s).

    • Get test cases that change a specific output path or paths. If more than one output path is provided, it will return test cases that change all of the specified paths.

      Parameters

      • outputPath: string | string[]

        The output path or paths to check for in the changes set of each test case.

      Returns AbstractTestCase[]

      An array of AbstractTestCase instances that change the specified output path(s).

    • Retrieve all test cases that have a specific annotation and optional value.

      Parameters

      • annotation: string

        The annotation to filter test cases by.

      • Optionalvalue: any

        The optional value of the annotation to match.

      Returns AbstractTestCase[]

      An array of test cases that match the annotation and value.

    • Runs the specified test cases by name or by instance and returns an array of their results. If a test case name is provided, it will look up the corresponding test case instance in the suite and run it. If an instance of AbstractTestCase is provided directly, it will run that instance. Disabled test cases will be skipped and not included in the results.

      Parameters

      • testCases: string[] | AbstractTestCase[]

        An array of test case names or instances to run.

      Returns TestCaseResult[]

      An array of TestCaseResult objects for the executed test cases.

    • Run all test cases in the suite and return an array of their results. Disabled test cases will be skipped and not included in the results.

      Returns TestCaseResult[]

      An array of TestCaseResult objects for the executed test cases.