Skip to content
Grzegorz Pabian edited this page Jul 21, 2014 · 1 revision

Overview

Page builders are plugins used during test context preparation process.

Structure

A typical page builder should expose a build function. For more advanced builders you can use attach and init API - check Structure of a plugin section for more details.

Example:

module.exports = {
    name: 'bender-pagebuilder-example',

    build: function (data) {

        // alter the data i.e. add some HTML to the data.parts array

        return data;
    }
};

Data object

Data object contains all the information about a test:

  • String id - the test's ID
  • String group - name of the test's group
  • String js - a path to the test's code
  • String html - a path to the test's HTML template
  • Array tags - a list of the test's tags
  • Object framework - the test's framework
  • Array applications - a list of the applications used in the test

It could contain some other information added by the test builders.

There's also an additional field called parts. It's an array containing bits of HTML code that will be combined into a single HTML - a test page - using dom-combiner (check dom-combiner's project page to see how it works).

Example:

{
    id: 'tests/html',
    html: 'tests/html.html',
    js: 'tests/html.js',
    tags: [ 'tests', 'html' ],
    include: '%BASE_PATH%assets/helpers.js,%BASE_PATH%assets/results.js',
    framework: {
        name: 'jasmine',
        files: [ ... ],
        js: [ ... ],
        css: [ ... ]
    },
    applications: [
        {
            name: 'ago',
            path: 'lib/',
            url: 'ago/',
            js: [ ... ],
            css: [ ... ]
        }
    ],
    group: 'Core',

    parts: [ ... ] // here you should add new bits of HTML for a test page
}

A page builder should return the received data object or a promise for this object if a part of the builder's code works asynchronously.

The promise should be compatible with Promises/A+ specification.

Clone this wiki locally