Dependency inside a subcomponent not getting instantiated during unit test

I have a parent component with a child:

parent.ts

...
selector: 'parent'

parent.html

<child></child>

In both the parent and child I have a service that provides an observable that both are subscribed to:

parent.ts & child.ts

constructor(private service: Service){}
ngOnInit() {
    this.service.method()...
}

And finally, I have a unit test for the parent component:

beforeEach(async () => {
    await TestBed.configureTestingModule({
        declarations: [ParentComponent],
        imports: [
            ChildModule,
            ParentModule
        ],
        providers: [Service],
}).compileComponents();

beforeEach(() => {
    fixture = TestBed.createComponent(ParentComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

...

it('should create page properly', () => {
    component.prop = prop; // prop is defined elsewhere; not really relevant
    fixture.detectChanges(); // <-- failing here
    expect(component).toBeTruthy();
  });

I'm getting the error: Cannot read property 'method' of undefined. The stack trace refers to the service in the child component. And as I understand it, the error is from the instantiation of the child component. How would I provide the service to the child in this case?

Thanks

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum