0

I've recently upgraded from Angular 12 to 13, which broke the Jest test for AppComponent, with the errors centring on MSAL. I updated @azure/msal-angular and @azure/msal-browser to their latest v2 packages, but this made no difference. I looked up the angular13-rxjs7-sample-app and aligned my app.component.spec.ts with that of the sample app - this helped to solve the initial error I was facing (NG0204: Can't resolve all parameters for MsalService: (?, ?).) but has thrown (Importing MsalModule which does not have a ɵmod property) instead, and this error I can't resolve.

  Importing MsalModule which does not have a ɵmod property

  10 |   beforeEach(waitForAsync(() => {
> 11|     TestBed.configureTestingModule({
     |             ^
  12|       imports: [
  13|         RouterTestingModule,
  14|         AppModule

Has anyone encountered this, and/or could shed some light on how I resolve this?

Here are my configuration details/relevant code:

  • Core Library: @azure/msal-browser 2.37.0

  • Wrapper Library: @azure/msal-angular 2.5.7

  • MSAL Configuration

     { 
       auth: {
          clientId: {{ClientId}},
          authority: 'https://' + {{TenantId}} + '.b2clogin.com/' + {{TenantId}} + '.onmicrosoft.com/' + {{Policy}},
          knownAuthorities: [{{TenantId}} + '.b2clogin.com'],
          redirectUri: {{RedirectUri}},
          postLogoutRedirectUri: {{RedirectUri}},
          navigateToLoginRequestUrl: true
      },
      cache: {
         cacheLocation: 'sessionStorage',
         storeAuthStateInCookie: false,
      }
    }
    
  • app.component.spec.ts

     import { TestBed, waitForAsync, ComponentFixture } from '@angular/core/testing';
     import { RouterTestingModule } from '@angular/router/testing';
     import { AppComponent } from './app.component';
     import { AppModule } from './app.module';
    
     describe('AppComponent', () => {
       let component: AppComponent;
       let fixture: ComponentFixture<AppComponent>;
    
       beforeEach(waitForAsync(() => {
         TestBed.configureTestingModule({
           imports: [
             RouterTestingModule,
             AppModule
           ],
           declarations: [
             AppComponent
           ]
         }).compileComponents();
       }));
    
       beforeEach(() => {
         fixture = TestBed.createComponent(AppComponent);
         component = fixture.componentInstance;
         fixture.detectChanges();
       });
    
       it('should create the app', () => {
         const fixture = TestBed.createComponent(AppComponent);
         const app = fixture.debugElement.componentInstance;
         expect(app).toBeTruthy();
       });
     });
    
Venator
  • 224
  • 3
  • 12

0 Answers0