title: TypeError: Cannot read properties of undefined (reading 'id')
body: <p>I have this error in my terminal:</p>
  <blockquote>
  <p>TypeError: Cannot read properties of undefined (reading 'id')</p>
  </blockquote>
  <p>I'm trying to test the call to an API, but the error appears.</p>
  <p>My function:</p>
  <pre><code>itemToForm = () =&gt; {
      this.api.send(this.component, 'get',
          { lang: 'ES', filter: { id: this.item['id'] } }
      ).then(resEsp =&gt; {
          this.item = resEsp['data'][0];
          this.api.send(this.component, 'get',
              { lang: 'EN', filter: { id: this.item['id'] } }
          ).then(res =&gt; {
              let itemEng = res['data'][0];
              let fields = this.formDef.map(register =&gt; register.filter(
                  field =&gt; field['register_table'].indexOf('traduction') !== -1
              ).map(
                  field =&gt; field['field_name'])
              ).filter(register =&gt; register.length);
  
              fields = fields.length ? fields[0] : [];
  
              if (itemEng) {
                  this.item = Object.keys(itemEng).reduce((obj, key) =&gt; {
                      obj[key] = this.item[key];
                      if (fields.indexOf(key) !== -1) {
                          obj[key + '_eng'] = itemEng[key];
                      }
                      return obj;
                  }, {});
              }
  
              if (this.item) {
                  this.setForm();
              }
          })
      })
  }
  </code></pre>
  <p>My specification file:</p>
  <pre><code>it('should call api.send', () =&gt; {
      let spy1 = spyOn(api, 'send');
      let item = {
          id: 1,
          name: 'test',
      }
  
      component.addItem(item);
      component.itemToForm();
  
      expect(spy1).toHaveBeenCalled();
  });
  </code></pre>