This answer is different than the others posted here. Starting with Angular 17, the RouterTestingModule
is deprecated. For my use case, after upgrading to Angular 17, my VsCode began flagging this deprecation:
RouterTestingModule must be replaced by provideRouter
, but note this is a provider now, not an import. So the following error was thrown by the Jasmine compiler when provideRouter was placed under imports:
The solution was to simply move the provider to where it should have gone (under providers) - and the error was no longer thrown:
This blog entry shows a full example using provideRouter.