import { CoreTestingModule } from '@abp/ng.core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { VendorPurchasesComponent } from './vendor-purchases.component';
describe('VendorPurchasesComponent', () => { let component: VendorPurchasesComponent; let fixture: ComponentFixture<VendorPurchasesComponent>;
beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [VendorPurchasesComponent], imports: [CoreTestingModule.withConfig()] }).compileComponents(); });
beforeEach(() => { fixture = TestBed.createComponent(VendorPurchasesComponent); component = fixture.componentInstance; fixture.detectChanges(); });
it('should create', () => { expect(component).toBeTruthy(); }); });
If I add providers:
import { INCUDE_LOCALIZATION_RESOURCES_TOKEN, LocalizationService } from '@abp/ng.core'; import { CoreTestingModule } from '@abp/ng.core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { VendorPurchasesComponent } from './vendor-purchases.component';
describe('VendorPurchasesComponent', () => { let component: VendorPurchasesComponent; let fixture: ComponentFixture<VendorPurchasesComponent>;
beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [VendorPurchasesComponent], imports: [CoreTestingModule.withConfig()], providers: [ LocalizationService, { provide: INCUDE_LOCALIZATION_RESOURCES_TOKEN, useValue: false }] }).compileComponents(); });
beforeEach(() => { fixture = TestBed.createComponent(VendorPurchasesComponent); component = fixture.componentInstance; fixture.detectChanges(); });
it('should create', () => { expect(component).toBeTruthy(); }); });
I still get error from LocalizationService instant method:
TypeError: Cannot read properties of undefined (reading 'instant') at new VendorPurchasesComponent (projects/SCM.Analytics/projects/analytics/src/lib/vendor/components/vendor-purchases/vendor-purchases.component.ts:21:54) at NodeInjectorFactory.factory (ng:///VendorPurchasesComponent/ɵfac.js:4:10) at getNodeInjectable (node_modules/@angular/core/fesm2020/core.mjs:3436:44) at createRootComponent (node_modules/@angular/core/fesm2020/core.mjs:12289:35) at ComponentFactory.create (node_modules/@angular/core/fesm2020/core.mjs:12170:25) at apply (node_modules/@angular/core/fesm2020/testing.mjs:24238:51) at _ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:412:30) at ProxyZoneSpec.onInvoke (node_modules/zone.js/fesm2015/zone-testing.js:287:39) at _ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:411:56) at Object.onInvoke (node_modules/@angular/core/fesm2020/core.mjs:24178:33)