Skip to main content
Version: 3.x

Testing

Testing is an important part of the development process. It helps to ensure that the code is working as expected and that it is not breaking any existing functionality. In this section, we will cover all the tools and utilities that we provide for testing.

Since version 3.4

createFrontCommerceProviderStub

This function is used to create a stub for the FrontCommerceProvider component. It is useful for testing components that depend on the FrontCommerceProvider component.

Props (optional)

PropDescriptionTypeLink
deviceDevice typeDeviceLink
messagesTranslations messagesRecord<string, string>-
isContributionModeEnabledContribution mode statusboolean-
publicConfigPublic configPublicConfigLink

Example

import { createFrontCommerceProviderStub } from "@front-commerce/core/testing";

const FrontCommerceProviderStub = createFrontCommerceProviderStub(/* props */);

makeDataLoaderStub

The usage is exactly the same as the original makeDataLoader api.

Example

import { makeDataLoaderStub } from "@front-commerce/core/testing";
import CategoryLoader from "./CategoryLoader";

const createSUT = (mockServer) => {
const axiosInstance = axios.create({
baseURL: `${mockServer.url}/api/rest`,
timeout: 50000,
});
return CategoryLoader(makeDataLoaderStub)(axiosInstance);
};