Skip to content
Grzegorz Pabian edited this page Mar 26, 2015 · 9 revisions

Overview

Directives are special comments added at the top of the test file. They can be used and defined by plugins.

Predefined directives

bender-tags

List of comma-separated tags describing the test file. These tags will be displayed on the dashboard and used for test filtering mechanism.

Example:

/* bender-tags: foo, bar, baz */

bender.test({...});

bender-include

List of comma-separated paths to JavaScript files that should be included in the test context. Can be used to include some common test data or functions.

This will add a script tag in the <head> section of the test context pointing to _assets/foo.js file.

You can use two special tags in a file path:

  • %BASE_PATH% - returns a base path of the test's group
  • %TEST_DIR% - returns a path to the test's directory

Example:

/* bender-include: _assets/foo.js, %BASE_PATH%_assets/tools.js */

bender.test({...});

bender-ui

Defines the behavior of the UI displayed in the single test run page i.e. when a test is executed from it's direct URL.

Three modes are available:

  • show - display results during entire test file execution (default behavior when bender-ui directive is omitted)
  • collapsed - display Expand the results button in the top right corner of the test page, the results will expand automatically once the testing is done
  • none - do not display anything on the screen until the testing is done, this can be used in tests that are heavily modifying <body> tag and its' contents, or to avoid spoiling document.elementFromPoint(x, y) method's result

Custom directives

It's possible to add custom directives and use them within a plugin or a test page. A good practice is to namespace custom directives (e.g. in case there are several of them used in a single plugin).

Directive names should follow below naming convention:

bender-<pluginName>-<propertyName>

Example:

/* bender-custom-foo: bar */
/* bender-custom-bar-baz: qux */

During the test building process, the above directives will be translated to custom object:

custom: {
    foo: 'bar',
    bar: {
        baz: 'qux'
    }
}

and added to test's data object. This means, it can be accessed from a test builder, page builder or even a test context using bender.testData object.

Clone this wiki locally