title: Angular testbed testing route cannot find module
body: <p>I am trying to test a simple redirect using TestBed but keep seeing the following error:</p>
  
  <blockquote>
    <p><code>Error: Uncaught (in promise): Error: Cannot find module ./pages/login/login.module#LoginPageModule</code></p>
  </blockquote>
  
  <p>My test is as follows:</p>
  
  <pre><code>describe('AppComponent', () =&gt; {
  
    let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy, platformIsSpy, storageSpy;
    let router: Router;
    let location: Location;
    let fixture, loginFixture;
    let comp: AppComponent;
  
    beforeEach(async(() =&gt; {
      statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']);
      splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']);
      platformReadySpy = Promise.resolve();
      platformIsSpy = Promise.resolve('ipad');
      platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy, is: platformIsSpy })
      storageSpy = jasmine.createSpyObj('Storage', ['get', 'set', 'clear', 'remove', 'ready']);
  
      TestBed.configureTestingModule({
        declarations: [AppComponent],
        imports: [
  
          IonicStorageModule.forRoot(),
          HttpClientTestingModule,
          LoginPageModule,
          RouterTestingModule.withRoutes(routes),
  
        ],
        schemas: [CUSTOM_ELEMENTS_SCHEMA],
        providers: [
          { provide: Storage, useClass: StorageMock },
          { provide: StatusBar, useValue: statusBarSpy },
          { provide: SplashScreen, useValue: splashScreenSpy },
          { provide: Platform, useValue: platformSpy },
        ],
      }).compileComponents();
  
      router = TestBed.get(Router);
      location = TestBed.get(Location);
      fixture = TestBed.createComponent(AppComponent);
      loginFixture = TestBed.createComponent
      comp = fixture.componentInstance;
      router.initialNavigation();
    }));
  
    it('navigates to "" redirects you to /login', fakeAsync(() =&gt; {
      router.navigate(['/login']);
      tick();
      expect(location.path()).toBe('/login')
    }));
  });
  </code></pre>
  
  <p>And my routes in <strong><code>app-routing.module.ts</code></strong> is:</p>
  
  <pre><code>export const routes: Routes = [
    {
      path: '',
      redirectTo: 'login',
      pathMatch: 'full'
    },
    {
      path: 'login', 
      loadChildren: './pages/login/login.module#LoginPageModule'
      // component: LoginPage
    },
    {
      path: 'manager-dashboard',
      canActivate: [AuthGuard],
      loadChildren: './pages/manager-dashboard/manager-dashboard.module#ManagerDashboardPageModule'
    },
  ];
  </code></pre>
  
  <p>And my <strong><code>LoginPageModule</code></strong> is:</p>
  
  <pre><code>const routes: Routes = [
    {
      path: '',
      component: LoginPage
    }
  ];
  
  @NgModule({
    imports: [
      CommonModule,
      FormsModule,
      IonicModule,
      RouterModule.forChild(routes)
    ],
    declarations: [LoginPage]
  })
  export class LoginPageModule {}
  </code></pre>
  
  <p>Is there something I need to do to make this work?</p>