title: Complex location in angular constructor is hard to test
body: <p>I am writing a test suite for a legacy app at work.
  The app is written in Angular, with Karma and Jasmine for tests.</p>
  <p>One of the components has this in the constructor:</p>
  <pre><code>if (this._location['_platformStrategy']['_platformLocation']['location']['pathname'].length &gt; 2) {
        this.showBack = true;
      } else {
        this.showBack = false;
      }
  </code></pre>
  <p>It causes the base test to fail and the component to not be created.
  The error I receive is:
  TypeError: Cannot read property '_platformLocation' of null</p>
  <p>How do I mock or stub the value in here?</p>
  <p>What I mean by base test is:</p>
  <pre><code>it(&quot;should create&quot;, () =&gt; {
      expect(component).toBeTruthy();
  });
  </code></pre>
  <p>I have tried multiple strategies to get around this and have not found a solution over the last few weeks. I have tried to mock the location in various places and to stub it.</p>