TypeError: Cannot read property 'getEcmUsername' of undefined

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2018 09:07 AM
Hi Team,
Developing on ADF 2.4.0, I am using Karma(v2.0.4) Jasmine(2.6.4) to perform unit testing of the custom components by executing command 'ng test -sourcemap=false'.
I am getting error -- TypeError: Cannot read property 'getEcmUsername' of undefined
**Please find attached a screenshot of the error.
Below is the .spec.ts file
Please note that earlier, I was using karma(v1.7.0) and later upgraded to v2.0.2 but not luck. I get the same error.
Please help me with the solution here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2018 03:12 AM
We have hundreds of working unit tests that are also open. Please refer to the existing tests to see how corresponding services used.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2018 05:29 AM
Hi Denys,
Any help to documentation links of existing tests would be really appreciated. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2018 08:51 AM
Hi,
I also tested a service that I created using Angular CLI. The service imports many ADF services that are used in it.
When i unit tested it by executing command 'ng test -sm=false' , I got couple of StaticInjectorError - No Provider...
So, I included all those services in the provider section of spec.ts file. Services included are:
After all this, now I get following error
TypeError: this.customLoader.init is not a function at TranslationService.use (webpack:///C:/MSDE/anshkuma/msim-cms-new/src/node_modules/@alfresco/adf-core/esm5/adf-core.js?:2100:27) at SafeSubscriber.eval [as _next] (webpack:///C:/MSDE/anshkuma/msim-cms-new/src/node_modules/@alfresco/adf-core/esm5/adf-core.js?:2067:19) at SafeSubscriber.__tryOrSetError (webpack:///C:/MSDE/anshkuma/msim-cms-new/src/node_modules/rxjs/_esm5/Subscriber.js?:253:16) at SafeSubscriber.next (webpack:///C:/MSDE/anshkuma/msim-cms-new/src/node_modules/rxjs/_esm5/Subscriber.js?:193:27) at Subscriber._next (webpack:///C:/MSDE/anshkuma/msim-cms-new/src/node_modules/rxjs/_esm5/Subscriber.js?:132:26) at Subscriber.next (webpack:///C:/MSDE/anshkuma/msim-cms-new/src/node_modules/rxjs/_esm5/Subscriber.js?:96:18) at BehaviorSubject._subscribe (webpack:///C:/MSDE/anshkuma/msim-cms-new/src/node_modules/rxjs/_esm5/BehaviorSubject.js?:33:24) at BehaviorSubject.Observable._trySubscribe (webpack:///C:/MSDE/anshkuma/msim-cms-new/src/node_modules/rxjs/_esm5/Observable.js?:177:25) at BehaviorSubject.Subject._trySubscribe (webpack:///C:/MSDE/anshkuma/msim-cms-new/src/node_modules/rxjs/_esm5/Subject.js?:107:51) at BehaviorSubject.Observable.subscribe (webpack:///C:/MSDE/anshkuma/msim-cms-new/src/node_modules/rxjs/_esm5/Observable.js?:165:65)
I'd appreciate if you could let me know exactly how we can solve this testing issue.
