Currently, I am conducting unit-testing for a project that utilizes TypeScript with the Angular framework. I am using Karma with Mocha and Chai frameworks for this purpose. The project includes an interface for the object, defined as follows:
interface ISolution {
_id: string;
paymentFrequency: PaymentFrequency;
};
Furthermore, the PaymentFrequency type is specified as:
type PaymentFrequency = 'MONTHLY' | 'ANNUAL' | 'SINGLE';
Within the controller,
open(solution: ISolution) { };
The issue arose when attempting to mock the solution as follows:
let solution = { _id: 'aa0', paymentFrequency: 'MONTHLY', ....};
let spy = sandbox.stub(controller, 'open').withArgs(solution);
Upon execution, TypeScript flagged an error stating "type string is not assignable to type paymentFrequency". If you have any suggestions on how to address this, please let me know.