how to set value to readonly property in typescript while unit testing

The solution for “how to set value to readonly property in typescript while unit testing” can be found here. The following code will assist you in solving the problem.

beforeEach(() => {
TestBed.configureTestingModule({
providers: [
MyService
]
});
service = TestBed.get(MyService);
const timeIntervals = ‘timeIntervals’;
Object.defineProperty(service, timeIntervals, { value: timeLists });
});

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in