Skip to main content

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.

PropertyTypeDescriptionDefault
historyHistoryHistory object, for more info see the docs.createBrowserHistory is used to create a new History object.
preloadfunctionPreload function to preload translations.Pre-defined function.
fetchedFetchedFetched instance.New instance.
clientDataClientDataClient instance.New instance.
appAppClientAppClient instance.New instance.
translatefunctionFunction for translating translation keys.Pre-defined function.