2

I'm following this tutorial. This is the only modern example I found to test the routing. In time I'd like to use mock components. Sadly, the delivered plunker does not work.

Router: App navigate to "" redirects you to /home

Expected '' to be '/home'.

and

Router: App navigate to "search" takes you to /search

Expected '' to be '/search'.

There is the same issue if I replace:

imports: [ RouterTestingModule.withRoutes(routes)] //by
imports: [ RouterModule.forRoot(routes)]

Do you guys have some ideas?

Community
  • 1
  • 1
Cerdicipe
  • 188
  • 3
  • 13

1 Answers1

0

It does not solve the issue. But one workaround is using E2E rather than unit tests.

describe('navigation', () => {

  it('root path should redirect to /app', () => {

    browser.get('http://localhost:49152');
    browser.getCurrentUrl().then((url) =>
      expect(url).toBe('http://localhost:49152/app')
    );

  });

});
Cerdicipe
  • 188
  • 3
  • 13