mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(http): Don't log fetch warning in tests. (#59049)
Prior to this commit, we were logging the `NOT_USING_FETCH_BACKEND_IN_SSR` error when `provideHttpTestingClient` and `PLATFORM_ID` were provided. fixes #59028 PR Close #59049
This commit is contained in:
parent
ae0802d63c
commit
ffae7df6e8
2 changed files with 13 additions and 1 deletions
|
|
@ -276,7 +276,14 @@ export class HttpInterceptorHandler extends HttpHandler {
|
|||
// a warning otherwise.
|
||||
if ((typeof ngDevMode === 'undefined' || ngDevMode) && !fetchBackendWarningDisplayed) {
|
||||
const isServer = isPlatformServer(injector.get(PLATFORM_ID));
|
||||
if (isServer && !(this.backend instanceof FetchBackend)) {
|
||||
|
||||
// This flag is necessary because provideHttpClientTesting() overrides the backend
|
||||
// even if `withFetch()` is used within the test. When the testing HTTP backend is provided,
|
||||
// no HTTP calls are actually performed during the test, so producing a warning would be
|
||||
// misleading.
|
||||
const isTestingBackend = (this.backend as any).isTestingBackend;
|
||||
|
||||
if (isServer && !(this.backend instanceof FetchBackend) && !isTestingBackend) {
|
||||
fetchBackendWarningDisplayed = true;
|
||||
injector
|
||||
.get(Console)
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ export class HttpClientTestingBackend implements HttpBackend, HttpTestingControl
|
|||
*/
|
||||
private open: TestRequest[] = [];
|
||||
|
||||
/**
|
||||
* Used when checking if we need to throw the NOT_USING_FETCH_BACKEND_IN_SSR error
|
||||
*/
|
||||
private isTestingBackend = true;
|
||||
|
||||
/**
|
||||
* Handle an incoming request by queueing it in the list of open requests.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue