Class: Spy (original) (raw)
Home
Modules
Namespaces
Classes
Interfaces
- AsymmetricEqualityTester
- Configuration
- Reporter
- ReporterCapabilities
- Spec
- SpyStrategy
- Suite
- ThrowUnlessFailure
Global
- afterAll
- afterEach
- beforeAll
- beforeEach
- describe
- expect
- expectAsync
- fail
- fdescribe
- fit
- it
- pending
- setSpecProperty
- setSuiteProperty
- spyOn
- spyOnAllFunctions
- spyOnProperty
- throwUnless
- throwUnlessAsync
- xdescribe
- xit
Spy
Namespaces
Members
(static) callData
Properties:
Name | Type | Description |
---|---|---|
object | object | this context for the invocation. |
invocationOrder | number | Order of the invocation. |
args | Array | The arguments passed for this invocation. |
returnValue | The value that was returned from this invocation. |
and :SpyStrategy
Accesses the default strategy for the spy. This strategy will be used whenever the spy is called with arguments that don't match any strategy created with Spy#withArgs.
Type:
Since:
- 2.0.0
Example
spyOn(someObj, 'func').and.returnValue(42);
Methods
withArgs(…args) → {SpyStrategy}
Specifies a strategy to be used for calls to the spy that have the specified arguments.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args | * | The arguments to match |
Since:
- 3.0.0
Returns:
Type
Example
spyOn(someObj, 'func').withArgs(1, 2, 3).and.returnValue(42);
someObj.func(1, 2, 3); // returns 42