Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Qarun-Qadir-Bissoondial/a4cf290a31724adee7d985bbca6d9b7c to your computer and use it in GitHub Desktop.
Save Qarun-Qadir-Bissoondial/a4cf290a31724adee7d985bbca6d9b7c to your computer and use it in GitHub Desktop.
Providing mock services
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { InventoryComponent } from './inventory.component';
import { InventoryService } from '../inventory.service';
import { MockInventoryService } from 'src/testing/inventory.mock.service';
fdescribe('InventoryComponent', () => {
let component: InventoryComponent;
let fixture: ComponentFixture<InventoryComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ InventoryComponent ],
providers: [
{ provides: InventoryService, useClass: MockInventoryService }
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(InventoryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment