Jasmine Framework
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2018 11:17 PM
Hi,
I am new of Jasmine Framework , Can you please explain me how to use jasmine in service now and give me one example.
Regards,
GCS
- Labels:
-
Automated Test Framework
- 5,258 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2018 11:21 PM
Hi,
https://developer.servicenow.com/blog.do?p=/tags/jasmine/
would be helpfule

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2018 11:37 PM
Please see a below example:
function(outputs, steps, stepResult, assertEqual) {
// add test data in the array testEmails
var one = 1,
two = 2;
var emailValid = new EmailValid();
describe('my suite of script tests', function() { //This is a test suite in Jasmine
it('should be one', function() { //This is a test
expect(one).toBe(1); //This will pass
});
it('should be one', function() { //This is a test
expect(two).toBe(1); //This will fail
});
it('should not be one', function() { //This is a test
expect(two).not.toBe(1); //This will pass
});
});
})(outputs, steps, stepResult, assertEqual);
// uncomment the next line to execute this script as a jasmine test
jasmine.getEnv().execute();
Additional note, Jasmine is a behavior driver framework and can be used in combination with Javascript syntaxes for array traversing. I like this power to write parameterized cases.
We can also use any of the existing Script Include in Jasmine.
Please find an example here https://community.servicenow.com/community?id=community_question&sys_id=5752e955dbeb5304feb1a851ca961941
The example there uses both parameterization and Script Include.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2018 11:52 PM
Here is a direct URL for the answer
https://community.servicenow.com/community?id=community_question&sys_id=5752e955dbeb5304feb1a851ca961941&anchor=answer_191ba695dbef9304feb1a851ca96194e
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2018 06:33 PM
There are two example Jasmine tests out of the box:
- Failing Jasmine Test
- Jasmine Successful Test
Inside these are test steps that should show you how Jasmine is used if you search the sys_atf_test table. Basically there are three parts to each test:
- before (or beforeEach) - any setup you need to do for a test
- it - which is what you're testing
- after (or afterEach) - any clean up you need to do after a test
Jasmine is a common library used for JavaScript testing and isn't specific to ServiceNow. You're probably better off starting with their doco here.