React Test Stepper
A HOC to step throught actions in order to test a Component.
# Using yarnyarn add --dev react-test-stepper# Or using npmnpm install --dev react-test-stepper
The idea of this package is to assert conditions while making some changes or steps to a component.
The only funcion exported is
setUpStepper(renderFunction: (this) => ReactComponent, steps: (props, this) => null) => ReactComponent.
This function has two arguments:
renderFunction: The function is used as the render function. The this object is changed to the hoc's one. In addition, it receives that component's this as first argument.
steps: It's an array of functions. Each function should be an step. The this object is changed to the hoc's one. Two arguments are passed:
propsof the hoc.
- hoc's this
The function returns a React Component.
Note: Each step is executed on componentDidMount / componentDidUpdate phase, so all steps should trigger that phases.
See the example.
A simple example is testing something that involves url triggering. The following example is done with React Router.
Fetching function is called