var QUnit = require("qunit/qunit");
QUnit.module('Module 1:');
QUnit.test("Test 1", function(assert) {
assert.ok(true, 'Passing assertion');
assert.ok(false, 'Failing assertion');
});
require("qunit/runner").run();
The next section will use this example to explore the main steps in using QUnit for testing server-side scripts.
To get a reference to the latest QUnit in this module, use the alias qunit/qunit
path and require
it:
var QUnit = require("qunit/qunit");
Or to get reference to a specific version:
var QUnit = require("qunit/qunit-2.0.1");
In this example the reference is to QUnit 2.0.1. Change as appropriate.
Note that all instances of QUnit supplied by such require
invocations are singletons.
Develop Qunit tests as usual. Just bear in mind that this is server-side environment and don't count on browser JS environment and objects like window or document.
QUnit.module('Module 1:');
QUnit.test("Test 1", function(assert) {
assert.ok(true, 'Passing assertion');
assert.ok(false, 'Failing assertion');
});
To run the tests and dispatch results, with Dirigible Test Runner use:
require("qunit/test-runner").run();
If you use a specific version (not the latest) of QUnit from this module, you need to supply it explicitly as argument to the service method:
require("qunit/test-runner").run(QUnit);
Test results are available on the Dirigible server console and via the Test Runner Service by default. You can opt out of either of these or both. The run
method has an optional second argument, which is a configuration object that can be used to disable the default reporters in use:
require("qunit/test-runner").run(QUnit, {
"disable-console-reporter": true,
"disable-service-reporter": true
});
Or omit the QUnit argument and supply only the configuration:
require("qunit/test-runner").run({"disable-console-reporter":true});
This project is copyrighted by SAP SE and is available under the Eclipse Public License v 2.0. See LICENSE and NOTICE.txt for further details.