How to use
npm i simple-stub --save-dev
To create a stub object, create a object and call
.createStub() with it as argument.
const simpleStub = ;const obj =a + 5;const stubObj = simpleStub;
If you now call
stubObj.f(1) it will behave like
obj.f(1) and return
6. The stub object will also save an array with "Call-Objects" for each function call which looks like this:
These "Call-Objects"-Arrays can be found under the path
After you made your calls you can use this data to make your assertions with your favorite library:
If your stub object needs a function named
calls. You can provide an options object to rename the stub objects build-in
const obj =a + 5;const stubObj = simpleStub;stubObj;console;// Prints: Call number is 1.
- You can not have deeply nested functions yet. Your functions need to be on the top level.
//will NOT work!const obj =g:a + 5;//NOPE!const stubObj = simpleStub;