Creating context
When writing tests for components or hooks a specially prepared context has to be created. The @archibald/testing package provides createContext function that can be used to create such a context.
import { createContext, TestingContext } from '@archibald/testing';
const testingContext: TestingContext = {};
const context = createContext(testingContext);
Options
When using createContext a set of options has to be provided. Interface TestingContext is used to type the options object.
| Property | Type | Description | Default |
|---|---|---|---|
| history | History | History object, for more info see the docs. | createBrowserHistory is used to create a new History object. |
| preload | function | Preload function to preload translations. | Pre-defined function. |
| fetched | Fetched | Fetched instance. | New instance. |
| client | DataClient | DataClient instance. | New instance. |
| app | AppClient | AppClient instance. | New instance. |
| translate | function | Function for translating translation keys. | Pre-defined function. |