


















![Spying Matchers expect(x).toHaveBeenCalled() expect(x).toHaveBeenCalledWith(arguments) expect(x).not.toHaveBeenCalled() expect(x).not.toHaveBeenCalledWith(arguments) spyOn(x, 'method').andCallThrough(): spies on AND calls the original function spied on spyOn(x, 'method').andReturn(arguments): returns passed arguments when spy is called spyOn(x, 'method').andThrow(exception): throws passed exception when spy is called spyOn(x, 'method').andCallFake(function): calls passed function when spy is called Spy Properties callCount: returns number of times spy was called mostRecentCall.args: returns argument array from last call to spy. argsForCall[i] returns arguments array for call i to spy.](https://image.slidesharecdn.com/jasmine-110606123527-phpapp02/75/Testing-Javascript-with-Jasmine-20-2048.jpg)









Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks and does not require a DOM. It has a clean, obvious syntax for writing tests using specs, expectations, suites, matchers, spies, and handling asynchronous code. Jasmine can be used with HTML, Ruby, NodeJS, Java, and other platforms/languages.



















![Spying Matchers expect(x).toHaveBeenCalled() expect(x).toHaveBeenCalledWith(arguments) expect(x).not.toHaveBeenCalled() expect(x).not.toHaveBeenCalledWith(arguments) spyOn(x, 'method').andCallThrough(): spies on AND calls the original function spied on spyOn(x, 'method').andReturn(arguments): returns passed arguments when spy is called spyOn(x, 'method').andThrow(exception): throws passed exception when spy is called spyOn(x, 'method').andCallFake(function): calls passed function when spy is called Spy Properties callCount: returns number of times spy was called mostRecentCall.args: returns argument array from last call to spy. argsForCall[i] returns arguments array for call i to spy.](https://image.slidesharecdn.com/jasmine-110606123527-phpapp02/75/Testing-Javascript-with-Jasmine-20-2048.jpg)







