Skip to content

Instantly share code, notes, and snippets.

@edezekiel
Created March 11, 2023 15:57
Show Gist options
  • Save edezekiel/4b4865cba619e20c86a399e91fbff98c to your computer and use it in GitHub Desktop.
Save edezekiel/4b4865cba619e20c86a399e91fbff98c to your computer and use it in GitHub Desktop.
Mock service provided to component using constructor-based DI
import { DemoService } from '../demo.service';
import { DemoComponent } from './demo.component';
describe('DemoComponent', () => {
it('should create', () => {
const serviceMock = { getWidgets: jest.fn() };
const component = new DemoComponent(serviceMock as DemoService);
expect(component).toBeTruthy();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment