Skip to content

Latest commit

 

History

History
78 lines (59 loc) · 2.92 KB

README.md

File metadata and controls

78 lines (59 loc) · 2.92 KB

Jasmine Dirigible Module

Eclipse License GitHub contributors

Use

Example

var j = require("jasmine/jasmine");
var jasmine = j.core(j);
var env = jasmine.getEnv();

var $$j = j.interface(jasmine, env);

$$j.describe("A suite is just a function", function() {
	$$j.it("and has a positive case", function() {
		$$j.expect(false).toBe(true);
	});
	$$j.it("and can have a negative case", function() {
		$$j.expect(false).not.toBe(true);
	});
});

require("jasmine/runner").run(env);

The next section will use this example to explore the main steps in using Jasmine for testing server-side scripts.

Load Jasmine and create context environment

To get a reference to the latest Jasmine in this module, use the alias jasmine/jasmine path and require it:
var j = require("jasmine/jasmine");
Or to get reference to a specific version:
var j = require("jasmine/jasmine-2.5.1");
In this example the reference is to Jasmine 2.5.1. Change as appropriate.

Further, setup test environment as you normally would with Jasmine:

var jasmine = j.core(j);
var env = jasmine.getEnv();

var $$j = j.interface(jasmine, env);

Develop tests

Develop Jasmine 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.

$$j.describe("A suite is just a function", function() {
   
    $$j.it("and has a positive case", function() {

		$$j.expect(false).toBe(true);
	});
	
	$$j.it("and can have a negative case", function() {
		$$j.expect(false).not.toBe(true);
	});	  

});

Run tests

To run the tests and dispatch results, with Dirigible Test Runner use:
require("jasmine/test-runner").run(env);

Test results

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("jasmine/test-runner").run(env, {
    "disable-console-reporter": true,
    "disable-service-reporter": true
  });

You can also control the output of the console reporter with the prettyPrint configuration property. A value of boolean true will indent and insert new line characters to layout more human readable JSON output. This is the default. A value of boolean false will write the output in more compact form.

License

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.