ServiceNow client and server-side testing based on Jasmine
Snow-tester can be installed in a ServiceNow instance running Fuji or later using the update set located here:
update_sets/snow-tester-version.xml
That update set contains the entire application while the rest of this repository contains only the scripting components. The scripting components are separated out to ease coding using an IDE.
Once installed (committed) in a ServiceNow instance, you can do some server-side testing. A means of doing client-side testing will be available soon.
At a high-level there are two steps in using Snow Tester: writing a Tester Suite and then running it.
- Go to Snow Tester > Tester Suites
- Click New
- Enter a Name such as 'Example.spec'
- Enter a Jasmine 1.3 suite in Script, such as the below examples
- Click Save or Update
- Go to the Tester Suite you want to run
- Click Run
- Test output will appear at the top of the form and will simultaneously be logged in Snow Tester > Log
gs.include("SnowLib.Tester.Suite");
var reporter = new SnowLib.Tester.TextReporter();
SnowLib.Tester.Suite.getByName('Example.spec').run(reporter);
var resultsText = reporter.getResults().output;
The variable resultsText would then hold output like the results given in Examples.
Snow-runner 0.0.3 and later includes support for running server-side Tester Suites from a local command line, by using the --suite argument:
$ node run.js YWRtaW46YWRtaW4=@demo001 --suite 'Example.spec'
Test results would then be dumped to the console, in the same text format as the results given in Examples.
The following is an example Jasmine 1.3 suite, taken from Jasmine documentation.
describe("A suite", function() {
it("contains spec with an expectation", function() {
expect(true).toBe(true);
});
});
The above should return results like:
.
1/1 passed, 0 failed in 0.003s
The following example will produce a failure and also shows how to use the jasmine log.
describe("A suite", function() {
it("contains spec with an expectation", function() {
jasmine.log('Setting up for failure')
expect(true).toBe(false);
});
});
The above should return results like:
✗
✗ A suite contains spec with an expectation.
Setting up for failure
✗ Expected true to be false.
0/1 passed, 1 failed in 0.003s