The innovaphone.test.js lib provides a simple framework for Javascript Unit tests. Scripts can be defined to execute "exe" and "chk" commands. With the "exe" commands mockup objects are addressed to perform simulated functions. With the "chk" commands it is verified that the correct functions of the mockup objects are called.

The scripts are defined as Javascript files, which push objects containing the tests into a global testScrips array.

The user has to provide a test.htm file, which includes all the necessary script and css files and a run.htm, which defines the tests to be executed for automatic tests.

innovaphone.test Namespace

innovaphone.test Namespace

The innovaphone.test.js lib defines an object innovaphone.test for all functions related to the Javascript unit test environment.


This is an object, which should be used as prototype for each object, which needs to be addressed by the test scripts. Typically mockup objects for interfaces use this. The Function init(id) of this object is used to push the object into the innovaphone.test.objs array, in which it can be found by the id.

Internal function, which is used to start the execution of a test script. Typicall the innovaphone.test Console uses this function.


Internal function to execute the next test step. If the test step addresses a mockup object as "obj", this mockup object is found in innovaphone.test.objs and the function exe of this object is called.


Function, which can be called by a mockup object to verify if the detected operation is expected according to the test script. It returns the args object defined in the test script so that the mockup object can verify all parameters.


Internal function to reset everything for the next test. innerHTML of document.body is set to null.


Constructor function to create a myApps Start object as mockup. This is needed to Test a complete App


Constructor function which allocales the test console. The console is displayed as a movable div on top of the module to be tested. It provides the following functions


The function innovaphone.ui1.nodePrototype.testId is set to not only set the id of the object as in the original function, but also to allocate an innovaphone.test.Obj object, so that this object can be addressed from the test script.

This object provides the following functions:

Calls dispatch event for the element
Set a property of the event
Executes xpath expressions to verify the element


Mockup for the real innovaphone.appwebsocket.Connection object. The script file innovaphone.appwebsocket.Connection.js which contains the "real" AppWebsocket lib should not be used.


Scripts can be loaded as Javascript files. For the manual tests, the console allows to load these scripts from the local file system. The files are executed with the eval function.

The javascript files for test scripts should contain instances as follows for each script (the first line is only needed once).

var testScripts = testScripts || [];

    title: TITLE;,
    file: FILE,
    delay: DEFAULT-DELAY,
    run: [
    steps: [
        { cmd: CMD;, obj: OBJ, op: OP, args: { ARGS }, delay: DELAY},
The title of the script. This is used to identify the script.
The filename can be put here. It is displayed in the logging when running all test automatically to identify where the script was defined.
Scripts identified by title which should be executed when automatically execute this script. Some other may need to be executed together with this script.
An optional default delay before each step when manually executing the script.
Can be either "exe" to execute a stelp or "chk" to verify an action
Operation as defined by the object addressed in this step.
Arguments as defined by the object addressed in the step
An optional delay before executing this step.


An html file is needed to load the module to be tested and the innovaphone.test lib. It is recommended to use the name test.htm for this file. The body onload event handler should be used to load a main Javascript object

A test.htm would look like this:

<!DOCTYPE html>
<html xmlns="">
    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" href="..." />
    <script type="text/javascript" src="..."></script>
    <script type="text/javascript" src="test.js"></script>
        ul,ol {}
        div::-webkit-scrollbar {
            width: 9px;
            height: 9px;

        div::-webkit-scrollbar-thumb {
            background-color: green;

<body onload="new NAME()">


A javascript file is needed for the module specific mockups and as main object to load the module to be tested

function NAME() {
    this.exe = function (op, args) {
        if (op == "init") {
            /* load module to be tested */
        else if(... more operations ...) {

    var con = new innovaphone.test.Console(this, "NAME", innovaphone.test);
NAME.prototype = innovaphone.test.obj;


A html file is used to define the tests to be executed automatically. It is recommended to use the name run.htm for this file. It should include all the files for the test scripts and uses postMessage to send the test to an iframe, in which test.htm is loaded

<!DOCTYPE html>
<html xmlns="" style="width:100%; height:100%">
    <meta charset="utf-8" />
    <script type="text/javascript" src="... script ..."></script>
    <script type="text/javascript">
        function test() {
            document.getElementById("test").contentWindow.postMessage(JSON.stringify(testScripts), "*");

<body onload="test()" style="width:100%; height:100%; margin:0px; padding:0px">
    <iframe title="test" id="test" style="width:100%; height:calc(100% - 5px); border:0px" src="test.htm"></iframe>