Wraps an existing Function to record all interactions, while leaving it up to the func to provide the behavior. This is useful when complex behavior not covered by the sinon.fake.* methods is required or when wrapping an existing function or method.
Creates a fake that returns a rejected Promise for the passed value. If an Error is passed as the value argument, then that will be the value of the promise. If any other value is passed, then that will be used for the message property of the Error returned by the promise.
Rejected promise
Creates a fake that returns a resolved Promise for the passed value.
Resolved promise
Creates a fake that returns the val argument
Returned value
Creates a fake that throws an Error with the provided value as the message property. If an Error is passed as the val argument, then that will be the thrown value. If any other value is passed, then that will be used for the message property of the thrown Error.
Returned value or throw value if an Error
fake expects the last argument to be a callback and will invoke it with the given arguments.
fake expects the last argument to be a callback and will invoke it asynchronously with the given arguments.
Creates a basic fake, with no behavior