Test Action Chains Using the vb-test Grunt Task

VB Studio’s grunt-vb-build NPM package includes a vb-test Grunt task that you can use to run the action chain tests in your visual application on your computer.

To use the vb-test Grunt task, you must set up your computer to build the visual application by installing Node.js and its package manage (npm). See Build Your Application With Grunt. Once you have installed the necessary tools, you need to save the sources for the visual application to your computer. You can get the sources of your visual application in one of the following ways:

  • Cloning the Git repository containing the sources
  • Exporting the visual application from VB Studio and extracting it to your local system

To test action chains using the vb-test Grunt task:

  1. In the command-line interface, navigate to the folder on your local system containing the package.json and Gruntfile.js files.
  2. Enter npm install to retrieve the node dependencies required to build the application.

    The install command retrieves the grunt-vb-build npm package defined in package.json.

  3. Enter the task names in the command-line interface to process your application sources, and then run the suite of tests that you defined in VB Studio.

    The following example shows how you execute these tasks, along with some of the parameters that they support:

    # First build application sources. This creates a build/processed directory with the built application assets.
    ./node_modules/.bin/grunt vb-process-local
    
    # Run the suite of action chain tests that you defined using one of the following options: 
    ## Headless mode:
    grunt vb-test 
    ## Test in the Chrome browser and set a timeout value:
    grunt vb-test --karma-browser=Chrome --mocha-timeout=60000
    
    The command-line options include the following:
    • karma-browser

      By default the tests run in headless Chrome, but you can pass Chrome to use the UI (window) mode instead.

      Example to run tests in Chrome UI:

      grunt vb-clean vb-process-local vb-test--karma-browser=Chrome

    • karma-debug

      Runs tests in Chrome UI mode. Suspends execution until you click the DEBUG button, at which point you can debug the app tests using Chrome DevTools. The Default value is false.

      Example to run tests in Chrome UI and debug mode:

      grunt vb-clean vb-process-local vb-test --karma-browser=Chrome --karma-debug

    • karma-log-level

      Sets the karma logging level. The default level is INFO, though you can change this to DEBUG, WARN, ERROR, or DISABLE.

      Example to run tests in Chrome UI with increased verbosity:

      grunt vb-clean vb-process-local vb-test --karma-browser=Chrome --karma-log-level=DEBUG

    • mocha-timeout

      Sets the timeout for Mocha tests (in milliseconds).

      Example to run tests in Chrome UI with a timeout for Mocha tests:

      grunt vb-test --karma-browser=Chrome --mocha-timeout=60000

    For more information on the supported command-line options, see vb-test.

  4. Check test results and code coverage reports in the build/tests/results directory.