Class: Spy

jasmine. Spy

new Spy()

Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks. Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine expectation syntax. Spies can be checked if they were called or not and what the calling params were. Spies are torn down at the end of every spec.
Spies can be created using spyOn, jasmine.createSpy or workaroundJSDocBug jasmine.createSpyObj. To check whether a variable contains a spy, please use jasmine.isSpy.
See:
  • spyOn, jasmine.createSpy, jasmine.createSpyObj

Members

and :jasmine.SpyStrategy

Type:
Since:
  • 1.9.0

argsForCall

Deprecated:

calls :jasmine.CallTracker

Type:
Since:
  • 1.9.0

mostRecentCall

Deprecated:

Methods

andCallFake(fakeFunc)

Calls an alternate implementation when a spy is called.
Parameters:
Name Type Description
fakeFunc function Method to be called
Deprecated:

andCallThrough()

Tells a spy to call through to the actual implemenatation.
Deprecated:

andReturn(value)

For setting the return value of a spy.
Parameters:
Name Type Description
value Object Value to be returned
Deprecated:

andThrow(exceptionMsg)

For throwing an exception when a spy is called.
Parameters:
Name Type Description
exceptionMsg String Exception to be thrown
Deprecated:

reset()

Resets all of a spy's the tracking variables so that it can be used again.
Deprecated: