Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TS2305: Module '@angular/core/testing' has no exported member async

I updated angular version from 17 to 18 and because of which some modules are no longer supporter especially in spec.ts files while importing them. Like async from @angular/core/testing and **provideRouterTesting **from @angular/router/testing and **HttpClientTestingModule **from @angular/common/http/testing. The exact error messages are as follows

@angular/router/testing' has no exported member provideRouterTesting TS2305: Module '@angular/core/testing' has no exported member async TS6385: HttpClientTestingModule is deprecated.

I need to know the alternatives for these modules. It will be helpful if anyone can update the alternative modules for these.

like image 319
Nixon Darius Avatar asked Sep 06 '25 19:09

Nixon Darius


1 Answers

The fix for

HttpClientTestingModule is deprecated.

Is to use provideHttpClientTesting

We should also include provideHttpClient


You can try fixing

'@angular/core/testing' has no exported member async

With using waitForAsync


You can try fixing

@angular/router/testing' has no exported member provideRouterTesting

With using RouterTestingModule.withRoutes (Non standalone)

Or

provideRouter and provideLocationMocks combined (Standalone).

Article on Angular Router Testing

like image 99
Naren Murali Avatar answered Sep 10 '25 03:09

Naren Murali