Difference between revisions of "Javascript jasmine"

From John Freier
Jump to: navigation, search
(Created page with " == RequireJS == Using RequireJS with Jasmine is totally possible. 1. To load in your modules to test, you must tell Jasmine-node to run using requireJS and not node-require....")
 
Line 14: Line 14:
  
 
https://github.com/mhevery/jasmine-node/blob/master/spec-requirejs/requirejs-wrapper-template.js
 
https://github.com/mhevery/jasmine-node/blob/master/spec-requirejs/requirejs-wrapper-template.js
 +
 +
3. Just setup you test. and done.
 +
 +
  require(['classService.js'], function(ClassService) {
 +
 
 +
  describe('ClassService Tests', function() {
 +
 
 +
  it('should default', function() {
 +
 
 +
  var classService = new ClassService();
 +
 
 +
  expect(classService.getName()).toBe('Ok');
 +
 
 +
  });
 +
 
 +
  });
 +
 
 +
  });

Revision as of 11:07, 28 May 2015

RequireJS

Using RequireJS with Jasmine is totally possible.

1. To load in your modules to test, you must tell Jasmine-node to run using requireJS and not node-require.

  jasmine-node --runWithRequireJs --requireJsSetup etc/spec/requirejs-setup.js etc/spec/ --captureExceptions

2. Need to setup the require-setup.js. This require the use of coping two files from github.

https://github.com/mhevery/jasmine-node/blob/master/spec-requirejs/requirejs-setup.js

and

https://github.com/mhevery/jasmine-node/blob/master/spec-requirejs/requirejs-wrapper-template.js

3. Just setup you test. and done.

 require(['classService.js'], function(ClassService) {
 	
 	describe('ClassService Tests', function() {
 		
 		it('should default', function() {
 			
 			var classService = new ClassService();
 			
 			expect(classService.getName()).toBe('Ok');
 			
 		});		
 	
 	});
 	
 });