AnsweredAssumed Answered

TypeError: Cannot read property 'getEcmUsername' of undefined

Question asked by anshu.kumar on Oct 19, 2018
Latest reply on Oct 24, 2018 by anshu.kumar

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

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { MatMenuModule } from '@angular/material/menu';
import { AuthenticationService, AppConfigService, AlfrescoApiService, StorageService, CookieService, LogService } from '@alfresco/adf-core';
import { HttpClientModule } from '@angular/common/http';

import { HeaderComponent } from './header.component';

describe('HeaderComponent', () => {
let component: HeaderComponent;
let fixture: ComponentFixture<HeaderComponent>;

beforeEach(async(() => {
imports: [RouterTestingModule, MatMenuModule, HttpClientModule],
declarations: [HeaderComponent],
providers: [AuthenticationService, AppConfigService, AlfrescoApiService, StorageService, CookieService, LogService],

beforeEach(() => {
fixture = TestBed.createComponent(HeaderComponent);
component = fixture.componentInstance;

it('should create', () => {


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.