mocha-mock
Mock library for mochajs
Basically I wanted to avoid the call to mock.verify
used in sinon
Example
const assert = const it mock =
API
it
returns an instance of mocha.it
but will also run any assertions setup by mock
during the it
block
mock
returns an instance of MockObject
MockObject.prototype.shouldReceive := (method: string) : MockObject
asserts that the given method is called
MockObject.prototype.once := () : MockObject
- must be called after
shouldReceive
- asserts that the method used in
shouldReceive
should be called exactly once
MockObject.prototype.twice := () : MockObject
- must be called after
shouldReceive
- asserts that the method used in
shouldReceive
should be called exactly twice
MockObject.prototype.times := (n: number) : MockObject
- must be called after
shouldReceive
- asserts that the method used in
shouldReceive
should be called exactlyn
times
MockObject.prototype.andReturn := (value: any) : MockObject
- must be called after
shouldReceive
- sets the value to be returned for the method used in
shouldReceive
MockObject.prototype.with := (...args: any) : MockObject
- must be called after
shouldReceive
- asserts that the method used in
shouldReceive
was called with the givenargs
MockObject.prototype.verify := () : boolean
- manually verify all of the assertions on the mock
- returns true if all assertions pass
- otherwise throws an an exception for the first assertion that failed