title: "Cannot assign to var because it is a read-only property." in angular test using Jasmine Test Framework
body: <p>I have a readonly property in one of the service in angular :</p>
  
  <pre><code>@Injectable({
    providedIn: 'root'
  })
  
  export class MyService {
    private readonly timeIntervals: any;
  }
  
  constructor(private readonly config: AppConfig) {
      this.timeIntervals = this.config.getResourceByKey(this.timeIntervalString);
  }
  
  
  
  getTimeIntervalMenuItem(): Array&lt;IElementData&gt;{
      const menuListItems = new Array&lt;IElementData&gt;();
      let index = 0;
      for (const item of Object.keys(this.timeIntervals)) {
        menuListItems.push({
          id: this.menuItem + index.toString(),
          label: this.timeIntervals[item].toString()
        });
        index++;
      }
      return menuListItems;
    }
  
  export interface IElementData {
      label?: string;
      value?: string;
      id?: string;
      active?: string;
  }
  </code></pre>
  
  <p>While writing test for the same service, how will I assign value to timeIntervals?</p>
  
  <p>What I did was:</p>
  
  <pre><code>beforeEach(() =&gt; {
      TestBed.configureTestingModule({
        providers: [
          MyService,
        ]
      });
      service = TestBed.get(MyService);
    });
  
  it('should generate total 7 menu items for dropdown', () =&gt; {
      const timeIntervals = 'timeIntervals';
      service[timeIntervals] = timeLists;
      const generatedMenu = service.getTimeIntervalMenuItem();
      expect(generatedMenu.length).toBe(7);
    });
  
  const timeLists = {
    3: '3',
    5: '5',
    10: '10',
    15: '15',
    20: '20',
    30: '30',
    60: '60'
  };
  </code></pre>
  
  <p>I am getting error as:</p>
  
  <blockquote>
    <p>Cannot assign to 'timeIntervals' because it is a read-only property.</p>
  </blockquote>
  
  <p>How to assign value to timeIntervals so that I can test my method</p>