Merk
Tilgang til denne siden krever autorisasjon. Du kan prøve å logge på eller endre kataloger.
Tilgang til denne siden krever autorisasjon. Du kan prøve å endre kataloger.
This article describes the module test file in Microsoft Dynamics 365 Commerce.
Use the module test file for local unit testing. It contains the mock data that the tests need.
Example
The following example shows a default test file created for a new module.
import { buildMockModuleProps} from '@msdyn365-commerce/core';
/// <reference types="jest" />
// tslint:disable-next-line:no-unused-variable
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import ProductFeature from '../productFeature';
import { IProductFeatureData } from '../productFeature.data';
import {
IProductFeatureConfig,
IProductFeatureProps
} from '../productFeature.props.autogenerated';
const mockData: IProductFeatureData = {
actionResponse: {
text: 'Sample Response Data'
}
};
const mockConfig: IProductFeatureConfig = {
showText: 'productFeature'
};
const mockActions = {};
describe('ProductFeature', () => {
let moduleProps: IProductFeatureProps<IProductFeatureData>;
beforeAll(() => {
moduleProps = buildMockModuleProps(mockData, mockActions, mockConfig) as IProductFeatureProps<IProductFeatureData>;
});
it('renders correctly', () => {
const component: renderer.ReactTestRenderer = renderer.create(
<ProductFeature {...moduleProps} />
);
const tree: renderer.ReactTestRendererJSON | null = component.toJSON();
expect(tree).toMatchSnapshot();
});
});
Set the mock data fields in this file.