Unit Testing/mocking Window properties in Angular2 (TypeScript)
<p>I'm building some unit tests for a service in Angular2.</p>

<p>Within my Service I have the following code: </p>

<p><code>var hash: string;
 hash = this.window.location.hash;</code></p>

<p>However when I run a test which contains this code, it will fail.</p>

<p>It'd be great to utilise all the features of Window, but as I'm using PhantomJs, I don't think this is possible (I have also tried Chrome which yields the same results).</p>

<p>In AngularJs, I would have resorted to mocking $Window (or at least the properties in question), but as there is not a lot of documentation for Angular2 unit testing I'm not sure how to do this.</p>

<p>Can anyone help? </p>