<p dir="auto">When I run unit test with nodejs and use inject in beforeEach then throw me an error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" TypeError: Cannot read property 'getXHR' of null
        at _runtimeCompilerBindings (angular2/src/testing/test_injector.ts:129:32)
        at Object.createTestInjectorWithRuntimeCompiler (angular2/src/testing/test_injector.ts:141:48)
        at Object.&lt;anonymous&gt; (angular2/src/testing/testing.ts:247:20)"><pre class="notranslate"><code class="notranslate"> TypeError: Cannot read property 'getXHR' of null
        at _runtimeCompilerBindings (angular2/src/testing/test_injector.ts:129:32)
        at Object.createTestInjectorWithRuntimeCompiler (angular2/src/testing/test_injector.ts:141:48)
        at Object.&lt;anonymous&gt; (angular2/src/testing/testing.ts:247:20)
</code></pre></div>
<p dir="auto">becouse DOM is null in nodejs :(</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="function _runtimeCompilerBindings() {
  return [
    provide(XHR, {useClass: DOM.getXHR()}),
    COMPILER_PROVIDERS,
  ];
}"><pre class="notranslate"><code class="notranslate">function _runtimeCompilerBindings() {
  return [
    provide(XHR, {useClass: DOM.getXHR()}),
    COMPILER_PROVIDERS,
  ];
}
</code></pre></div>
<p dir="auto">This issue was posted by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/francois-appliware/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/francois-appliware">@francois-appliware</a> under angular/vladivostok and was gaining traction until the repo was merged into this one. I'm posting it here for visibility.</p>
<blockquote>
<p dir="auto">Hi,<br>
I am working with the new router and had an issue that I "managed to resolve", but as I don't quite understand how everything works under the hood I prefer to open this issue and try to understand what is going on.</p>
<p dir="auto">In my application, I have a few routes as following :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{ path: '/dashboard', component: DashboardComponent },
{
    path: '/companies', component: CompanyComponent, children: [
        { path: '/details/:id', component: CompanyDetailComponent },
        { path: '/new', component: CompanyEditComponent },
        { path: '/', component: CompanyDetailComponent, index: true }
    ]
},
{
    path: '/keys', component: KeyComponent, children: [
        { path: '/details/:id', component: KeyDetailComponent },
        { path: '/new', component: KeyEditComponent },
        { path: '/', component: CompanyDetailComponent, index: true }
    ]
}"><pre class="notranslate"><code class="notranslate">{ path: '/dashboard', component: DashboardComponent },
{
    path: '/companies', component: CompanyComponent, children: [
        { path: '/details/:id', component: CompanyDetailComponent },
        { path: '/new', component: CompanyEditComponent },
        { path: '/', component: CompanyDetailComponent, index: true }
    ]
},
{
    path: '/keys', component: KeyComponent, children: [
        { path: '/details/:id', component: KeyDetailComponent },
        { path: '/new', component: KeyEditComponent },
        { path: '/', component: CompanyDetailComponent, index: true }
    ]
}
</code></pre></div>
<p dir="auto">When I am navigating from companies to keys, I have the following error :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Error {rejection: TypeError: Cannot read property '_routeConfig' of null
at GuardChecks.runCanDeactivate (http://l…, promise: ZoneAwarePromise, zone: Zone, task: ZoneTask, message: &quot;Uncaught (in promise): TypeError: Cannot read property '_routeConfig' of null&quot;}"><pre class="notranslate"><code class="notranslate">Error {rejection: TypeError: Cannot read property '_routeConfig' of null
at GuardChecks.runCanDeactivate (http://l…, promise: ZoneAwarePromise, zone: Zone, task: ZoneTask, message: "Uncaught (in promise): TypeError: Cannot read property '_routeConfig' of null"}
</code></pre></div>
<p dir="auto">So I went ahead and downloaded the code to see what was going on inside that "GuardChecks".</p>
<p dir="auto">For what I understand, it is used for the CanActivate / CanDeactivate (that I do not use in any of my components). Also, from what I understand, it is working with nullable values (in my case, where I don't have such guards).</p>
<p dir="auto">Problem is, at some point in adds a check with a null value that throws the previous error mentioned above.</p>
<p dir="auto">I managed to solve my issue by replacing the following line inside "router.js" inside the method GuardChecks.prototype.runCanDeactivate = function (component, curr)<br>
<code class="notranslate">var canDeactivate = curr._routeConfig ? curr._routeConfig.canDeactivate : null;</code><br>
by the following :<br>
<code class="notranslate">var canDeactivate = curr ? (curr._routeConfig ? curr._routeConfig.canDeactivate : null) : null;</code></p>
<p dir="auto">(Yes, it's ugly but that's a hotfix so I can continue working)<br>
I think the check can be set before the 'runCanDeactivate', where the checks are added, maybe in the traverseRoutes method inside GuardChecks.</p>
<p dir="auto">Is this a known bug or a real bug and needs a fix or is it intended ?</p>
<p dir="auto">Thank you.</p>
</blockquote>
<p dir="auto">This bug has been present in the 3.0.0 router since release and is still present in alpha-7. It makes the router unusable for production applications. Hopefully this can be resolved and released soon. Thanks!</p>