Writing your first test
Under the /src/webparts/packProductCatalog/components folder, create a new file called PackProductCatalog.test.tsx for testing the PackProductCatalog.tsx component. It is responsible for displaying products in the web part. In the following section, we’ll cover the implementation details and highlight the important elements you need to understand as an SPFx developer.
Organizing your tests
In our case, we want to test the product catalog component (the React component, not the web part), ensuring it displays the products in the UI correctly. We’ll start our test file by ensuring it has the following structure:
describe("Product catalog tests suite", () => {
it('Display the list of products retrieved from the list', async () => {
// Test implementation
});
}); The Jest framework provides multiple directives to help...