Helpers for testing reactables
npm install @reactables/testingTesting helpers for reactables
1. Installation
1. API
1. testFlow
1. FlowTest
1. Flow
1. FlowFactory
npm i -D @reactables/testing
FlowTest on a reactable.``typescript`
// T = reactable state
// S = reactable actions
// U = reactable dependencies
// V = expected result
type testFlow =
flowTest: FlowTest
) => void;
Configuration for testing a Flow on a reactable.
`typescript`
// T = reactable state
// S = reactable actions
// U = reactable dependencies
// V = expected result
export interface FlowTest
description: string;
factories: {
flow: FlowFactory;
reactable: (...deps: U) => Reactable
dependencies?: () => U;
};
expectedResult: V;
operator?: OperatorFunction
assertFunc?: (actual, expected) => void | boolean;
}
| Property | Description |
| -------- | ----------- |
| description | Describes the test. |
| factories.flow | FlowFactory that will create the flow to be tested. |
| factories.reactable | Factory method creating the reactable.
| factories.dependencies | Factory function creating the reactable's dependencies.
| expectedResult | Expected result for the test. |
| operator (optional) | Operator function for manipulating the final value emitted by the reactable's state observable.
| assertFunc (optional) | Function that will assert actual vs expected. (default isEqual)|
| actionInterval (optional) | Time interval between action calls in the flow run. (default 5000ms) |
Used to simulate a user flow. An array of functions used to envoke a reactable's action methods.
`typescript`
type Flow = (() => void)[];$3
Factory function for creating a Flow from a reactable's action methods.
`typescript``
type FlowFactory