Uncaught TypeError: Cannot read properties of undefined (reading 'BASE_URL')
TypeError: Cannot read properties of undefined (reading 'BASE_URL')
at Module.553 (http://localhost:9876/_karma_webpack_/webpack:/src/environments/environment.ts:16:71)
at __webpack_require__ (http://localhost:9876/_karma_webpack_/webpack:/webpack/bootstrap:19:1)
at Module.5012 (http://localhost:9876/_karma_webpack_/main.js:4167:74)
This is my spec file
describe('AdditionalBreaksComponent', () => {
let component: AdditionalBreaksComponent;
let fixture: ComponentFixture<AdditionalBreaksComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [AdditionalBreaksComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
{
provide: MatDialog,
useValue: jasmine.createSpyObj('MatDialog', ['open'])
},
{
provide: ToasterService,
useValue: jasmine.createSpyObj('ToasterService', ['success', 'error'])
},
{
provide: PertStaticService,
useValue: jasmine.createSpyObj('PertStaticService', ['getAllPlants'])
},
{
provide: AdditionalBreaksService,
useValue: jasmine.createSpyObj('AdditionalBreaksService', ['getAdditionalBreak', 'deleteAdditionalBreak'])
},
{
provide: ResourcePoolsService,
useValue: jasmine.createSpyObj('ResourcePoolsService', ['getResourcePools'])
},
{
provide: PsStationsService,
useValue: jasmine.createSpyObj('PsStationsService', ['getPsStations', 'getPsStationById'])
}
]
}).compileComponents();
fixture = TestBed.createComponent(AdditionalBreaksComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
}
);
And this is my component file
{
displayName: 'Additional Breaks'
}
];
constructor(
private formBuilder: FormBuilder,
private router: Router,
private route: ActivatedRoute,
private dialogService: MatDialog,
private toasterService: ToasterService,
private pertStaticService: PertStaticService,
private additionalBreaksService: AdditionalBreaksService,
private resourcePoolService: ResourcePoolsService,
private psStationService: PsStationsService
) {
super();
this.allowedNullableCustomFunctionColumns = ['psStationId'];
this.form = this.formBuilder.group({
search: '',
plant: this.all
});
this.plants = this.pertStaticService.getAllPlants();
}
I tired mocking the services but still got the error. I am not able to identify also what is causing the error?