npm install --save-dev stepperbox
StepperBox is a testing library for creating stub functions that invoke different callbacks at different steps. It works similarly to a Sinon spy, but is much simpler in its implementation and usage. This allows you to create much more explicit mock behavior without knowing any cryptic API.
var stepperbox = ;var stepper = ;stepper;stepper;;;// Outputs:// "Step 1", 5// "Step 2", 6
This can be further extended for testing by using
Function.prototype.bind to create curried versions of the stepper for stubbing multiple pieces. The below example shows how you could use stepper with proxyquire to stub the query function on a mysql connection pool.
var mymodule =;stepper;
Returns a stepper instance, a callable function with chainable methods defining the behavior of the function at each invocation. An array of callbacks may be provided to be used as the initial steps.
Calling the stepper function invokes each defined step as if it had been called directly, passing in all arguments received.
Returns a standalone function (without the stepper methods) which will be bound with the provided name as the first argument received (see the mysql example above).
Appends a callback step to the end of the current chain
Inserts a callback step at the specified index (0 based) in the sequence.
Syntactic sugar for
onCall. Inserts a callback step at the first, second or third positions, respectively.
Defines a callback to be invoked after the last step. Can be called multiple times to add more callbacks. Is reset by
Resets the stepper position to the first step.
Resets the stepper position, and removes all existing steps.
Resets the stepper position, and overwrites all existing steps with the callbacks provided in the array.
Returns the current step position as a zero based integer.
Returns the total number of steps currently on the stepper