title: Jasmine angular unit test length of undefined
body: <p>I have some function like this</p>
  <pre><code>  updateParts(enviromentContainsAllParts: PartsContainsAllParts): Observable&lt;boolean&gt; {
      const enviroment = cloneDeep(this.enviroment);
      enviroment.containsAllPart = enviromentContainsAllParts.containsAllPart;
      for (let index = 0; index &lt; enviromentContainsAllParts.parts.length; index++) {
        const currentPart = enviromentContainsAllParts.parts[index];
        enviroment.parts.push({
          size: currentPart.sizeOfEnviroment
        });
      }
      return of(true);
    }
  </code></pre>
  <p>When i am try to unit test this</p>
  <pre><code>it('should have change enviroment parts', () =&gt; {
    // GIVEN
    const enviroment = cloneDeep(fakeCurrentEnviroment);
    service.enviroment = enviroment;
    // WHEN
    service.updateParts(building).subscribe(data =&gt;
      expect(data).toBeTruthy()
    );
    // THEN
  });
  </code></pre>
  <p>I got error like this
  <strong>TypeError: Cannot read property 'length' of undefined</strong>
  Does anyone knows where I am getting wrong?</p>