Creating Jasmine test spec file for Injectable service with PopoverController

I’m attempting to add jasmine test files (*.spec.ts) to all of the injectable services I have in my Ionic Angular project.

Once I added the test file for a specific service that has an injectable PopoverController dependancy I got the following error:

NullInjectorError: R3InjectorError(DynamicTestModule)[MapLayerReportsService → PopoverController → PopoverController]: NullInjectorError: No provider for PopoverController!

I found this solution on S/O (jasmine - ionic 5 unit test with popover controller - Stack Overflow), which seems to have gotten rid of the error on one of my services, but the solution doesn’t work on my other services that have the same PopoverController dependancy.

With those I get a new error:

Error: Timeout - Async function did not complete within 5000ms (set by jasmine.DEFAULT_TIMEOUT_INTERVAL)

So, first of all, is the S/O solution correct? If so, what am I doing wrong? If not, how do I properly implement jasmine testing to a service that has a PopoverController dependancy.

Here’s my spec file:

import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TestBed, waitForAsync } from '@angular/core/testing';
import { PopoverController } from '@ionic/angular';

import { MapLayerRadarService } from './map-layer-radar.service';

describe('MapLayerRadarService', () => {
  let service: MapLayerRadarService;

  let popoverSpy = jasmine.createSpyObj('Popover', ['create', 'present', 'onDidDismiss', 'dismiss']);
  let popoverCtrlSpy = jasmine.createSpyObj('PopoverController', ['create']);
  popoverCtrlSpy.create.and.callFake(function () {
   return popoverSpy;
  beforeEach(waitForAsync(() => {
      providers: [ 
        { provide: PopoverController, useValue: popoverCtrlSpy }, 
      imports: [ HttpClientTestingModule ],
    service = TestBed.inject(MapLayerRadarService);
    (service as any);

  it('should be created', () => {

I found the issue. It was the waitForAsync(… in my test causing the issues. I’m not sure what that does or if I’ll need to at some point, but the test is now passing.