ngx-translate / core

The internationalization (i18n) library for Angular
MIT License
4.5k stars 572 forks source link

TypeError: Cannot read property 'subscribe' of undefined #1220

Open JairoRC opened 4 years ago

JairoRC commented 4 years ago

Hello friends! The first thing to thank for your work which has helped me a lot to create multilanguage applications, currently I am passing the tests with Karma in Angular9 obtaining the following error:

TypeError: Cannot read property 'subscribe' of undefined at at TranslatePipe.updateValue (http://localhost:9876/_karma_webpack_/node_modules/@ngx-translate/core/__ivy_ngcc__/fesm2015/ngx-translate-core.js:1508:1) at TranslatePipe.transform (http://localhost:9876/_karma_webpack_/node_modules/@ngx-translate/core/__ivy_ngcc__/fesm2015/ngx-translate-core.js:1549:1) at ɵɵpipeBind1 (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:36748:1) at LoginScreenComponent_Template (ng:///LoginScreenComponent.js:59:33) at executeTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:12010:1) at refreshView (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:11857:1) at refreshComponent (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:13295:1) at refreshChildComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:11586:1) at refreshView (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:11909:1) at renderComponentOrTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:11983:1)

I have tried different solutions, some of which obtained from various colleagues in forums without satisfactory result, The component has an empty controller, it is simply an html template that uses the translations pipeline.

raspyweather commented 4 years ago

Might you provide a minimum reproduction example?

muhammadzarif903 commented 2 years ago

Were

Hello friends! The first thing to thank for your work which has helped me a lot to create multilanguage applications, currently I am passing the tests with Karma in Angular9 obtaining the following error:

TypeError: Cannot read property 'subscribe' of undefined at at TranslatePipe.updateValue (http://localhost:9876/_karma_webpack_/node_modules/@ngx-translate/core/__ivy_ngcc__/fesm2015/ngx-translate-core.js:1508:1) at TranslatePipe.transform (http://localhost:9876/_karma_webpack_/node_modules/@ngx-translate/core/__ivy_ngcc__/fesm2015/ngx-translate-core.js:1549:1) at ɵɵpipeBind1 (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:36748:1) at LoginScreenComponent_Template (ng:///LoginScreenComponent.js:59:33) at executeTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:12010:1) at refreshView (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:11857:1) at refreshComponent (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:13295:1) at refreshChildComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:11586:1) at refreshView (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:11909:1) at renderComponentOrTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:11983:1)

I have tried different solutions, some of which obtained from various colleagues in forums without satisfactory result, The component has an empty controller, it is simply an html template that uses the translations pipeline.

Were you able to solve this ?

muremwa commented 3 months ago
const ts: jasmine.SpyObj<TranslateService> = jasmine.createSpyObj(
      'TranslateService',
      ['setDefaultLang', 'get'],
      { 'onTranslationChange': of({}), 'onLangChange': of({}), 'onDefaultLangChange': of({})},
    );
ts.get.and.returnValue(of({}));