ClientV2 has a lightweight integrated testing framework. It can be used to automatic testing of Client's own functionality as well as arbitrary conversations.

Running tests

  1. Open developer tools in your favorite browser (Ctrl + Shift + I)
  2. find the console, type in:
    • To run all tests: tests()
    • To run a collection of tests: tests.basic()
    • Run a single test: tests.basic. ... wait for autocomplete to show you suggestions and finish with the name of test you want to run ...

The current test cllections tree structure:

    basic.* - tests for core ClientV2 features
    twentyq.* - tests for 20 questions game

Adding custom tests

Add your custom tests to the /js/demoV2.js file.

Example test:

tests.my_custom_test = Test()            // test constructor
    .config({my_config_value: "value"})  // set configuration - these changes will be rolled back when the test finishes
    .context({user_name: "Marek"})       // set context - will be rolled back when the test ends
    .say("Hello")                        // simulate user input
    .expectText()                        // wait for any response - test will fail on error or timeout
    .say("Do you work properly?")        // simulate user input
    .expectText("Yes")                   // wait for response and check it's value to be "Yes"
    .say("Great, do you like bananas?")
    .expectText(/^(Yes)|(Maybe)/)        // assert by matching a regular expression
    .say("Choose a random number between 10 and 100")
    .expextText(function (text) { if (text < 10 || text > 100) return "it said a number out of allowed range"; }) // custom response validation