Encountering an Issue with Component Mocking
When attempting to mock a component, I am receiving the following error message: "Conversion of type '{ props: { index: number; AssignmentTitle: string; AssignmentDescription: string; AssignmentUtilizedHours: string; AssignmentScheduledHours: string; AssignmentStartDate: string; AssingmentEndDate: string; }; }' to type 'InsightsComponent' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Type '{ props: { index: number; AssignmentTitle: string; AssignmentDescription: string; AssignmentUtilizedHours: string; AssignmentScheduledHours: string; AssignmentStartDate: string; AssingmentEndDate: string; }; }' is missing the following properties from type 'InsightsComponent': percentage, toggle, trimZeroDecimal, render, and 5 more.ts(2352). The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.ts(2362)"
This error occurs in the context of my components class that looks like this:
import * as React from 'react';
export interface InsightsComponentProps {
index: number,
AssignmentTitle: string,
AssignmentDescription: string,
AssignmentUtilizedHours: string,
AssignmentScheduledHours: string,
AssignmentStartDate: Date,
AssingmentEndDate: Date
}
// Further code omitted for brevity...
Additionally, I have a test class that includes the following snippet:
import * as React from 'react';
import {InsightsComponent, InsightsComponentProps} from './statisticsComponent';
import {shallow,ShallowWrapper} from 'enzyme';
describe('Testing InsightComponent', () => {
const props = {
// Props defined here...
};
let wrapper = ShallowWrapper<InsightsComponentProps,any>(<InsightsComponent {props} /> );
My goal is to test the `trimZeroDecimal()` method within the component, but I am facing errors when trying to create an instance of the component class. Specifically, the below line is causing a compile-time error:
ShallowWrapper<InsightsComponentProps,any>(<InsightsComponent {props} /> );