Skip to content

Commit bdd3f82

Browse files
committed
Add docs for the new callsFake behavior
1 parent e0cfccc commit bdd3f82

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: docs/release-source/release/stubs.md

+16
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,22 @@ stub.called // false
211211

212212
213213

214+
#### `stub.callsFake(fakeFunction);`
215+
Makes the stub call the provided `fakeFunction` when invoked.
216+
217+
```javascript
218+
var myObj = {};
219+
myObj.prop = function propFn() {
220+
return "foo";
221+
};
222+
223+
sinon.stub(myObj, prop).callsFake(function fakeFn() {
224+
return 'bar';
225+
});
226+
227+
myObj.prop(); // 'bar'
228+
```
229+
214230
#### `stub.returns(obj);`
215231
Makes the stub return the provided value.
216232

0 commit comments

Comments
 (0)