With Custom Host

Sometimes it's helpful to pass your own host implementation. Let's see how we can do it with Spectator.

@Component({ selector: 'custom-host', template: '' })
class CustomHostComponent {
title = 'Custom HostComponent';
describe('With Custom Host Component', function () {
let host: SpectatorWithHost<ZippyComponent, CustomHostComponent>;
const createHost = createHostComponentFactory({
component: ZippyComponent,
host: CustomHostComponent
it('should display the host component title', () => {
host = createHost(`<zippy [title]="title"></zippy>`);
expect(host.query('.zippy__title')).toHaveText('Custom HostComponent');

We can pass a custom host component to the createHostComponentFactory() that will replace the default one.