rbalet / ngx-translate-multi-http-loader

A loader for ngx-translate that loads translations with http calls
MIT License
77 stars 15 forks source link

Something went wrong for the following translation file #23

Closed StanleyNavara closed 1 year ago

StanleyNavara commented 1 year ago

Getting the following error when using the library in Jest tests.

           console.error
             Something went wrong for the following translation file: shared-assets/i18n/general/nl.json

             at ../../node_modules/ngx-translate-multi-http-loader/fesm2015/ngx-translate-multi-http-loader.mjs:19:25
             at ../../node_modules/rxjs/src/internal/operators/catchError.ts:117:35
             at OperatorSubscriber._this._error (../../node_modules/rxjs/src/internal/operators/OperatorSubscriber.ts:79:13)
             at OperatorSubscriber.Object.<anonymous>.Subscriber.error (../../node_modules/rxjs/src/internal/Subscriber.ts:91:12)
             at OperatorSubscriber.Object.<anonymous>.Subscriber._error (../../node_modules/rxjs/src/internal/Subscriber.ts:124:24)
             at OperatorSubscriber.Object.<anonymous>.Subscriber.error (../../node_modules/rxjs/src/internal/Subscriber.ts:91:12)
             at OperatorSubscriber.Object.<anonymous>.Subscriber._error (../../node_modules/rxjs/src/internal/Subscriber.ts:124:24)
             at OperatorSubscriber.Object.<anonymous>.Subscriber.error (../../node_modules/rxjs/src/internal/Subscriber.ts:91:12)

           console.error
             this.handler.handle is not a function

             at ../../node_modules/ngx-translate-multi-http-loader/fesm2015/ngx-translate-multi-http-loader.mjs:20:25
             at ../../node_modules/rxjs/src/internal/operators/catchError.ts:117:35
             at OperatorSubscriber._this._error (../../node_modules/rxjs/src/internal/operators/OperatorSubscriber.ts:79:13)
             at OperatorSubscriber.Object.<anonymous>.Subscriber.error (../../node_modules/rxjs/src/internal/Subscriber.ts:91:12)
             at OperatorSubscriber.Object.<anonymous>.Subscriber._error (../../node_modules/rxjs/src/internal/Subscriber.ts:124:24)
             at OperatorSubscriber.Object.<anonymous>.Subscriber.error (../../node_modules/rxjs/src/internal/Subscriber.ts:91:12)
             at OperatorSubscriber.Object.<anonymous>.Subscriber._error (../../node_modules/rxjs/src/internal/Subscriber.ts:124:24)
             at OperatorSubscriber.Object.<anonymous>.Subscriber.error (../../node_modules/rxjs/src/internal/Subscriber.ts:91:12)

Followed this post on SO https://stackoverflow.com/questions/69051268/ngx-translate-multi-http-loader-something-went-wrong-for-the-following-transla but it gave the same errors. I checked and it does enter the HttpInterceptor and read out the header in the test runs.

All the tests are still passing even without the suggestions in the post, but is there a way to get rid of the errors in the test output?

rbalet commented 1 year ago

Hi @StanleyNavara, I've updated my stackoverflow answer.

Are you sure you're using httpBackend ?

StanleyNavara commented 1 year ago

We are using HttpBackend indeed, but we have also tried HttpClient before. Both get the same error and it is only during jest tests, not during runtime. Using version 9.2.0.

Edit: We also use a HttpInterceptor, does that matter for tests?

rbalet commented 1 year ago

@StanleyNavara well I do go honestly have no clue.

Could you open a question over stackoverflow?

Maybe someone have the answer there

umuero commented 1 year ago

had the "this.handler.handle is not a function" issue today, it turned out, we didn't update the loader.deps to HttpBackend TranslateModule.forRoot({ loader: { provide: TranslateLoader, useFactory: HttpLoaderFactory, deps: [HttpClient], // <- HttpBackend }, }),

rbalet commented 1 year ago

@umuero Well, closing the issue then :)