In the IData interface, there are optional properties available.
interface IData {
prop1: string,
prop2?: string
}
setObj(){
prop1 = 'abc';
prop2 = 'xyz';
let obj1 : IData = {
prop1: this.prop1,
prop2: this.prop2
}
}
During unit testing, an error is thrown when expecting the value of obj1.
expect(obj1).toEqual({
prop1: 'abc',
prop2: 'xyz' })
The argument '{prop1: string; prop2: string;}' cannot be assigned to the expected parameter type.