mercredi 18 novembre 2020

tests broken after updating Angular 9 to 10

After I updated Angular from 9 to 10 all my jest-tests are broken. They worked fine before the update. How do I fix this?

Here is one of my tests:

@Component({
  selector: 'prof-notifications-form',
  template: '',
})

describe('NotificationsFormComponent', () => {
  let component: NotificationsFormComponent;
  let fixture: ComponentFixture<NotificationsFormComponent>;

  beforeEach(
    waitForAsync(() => {
      TestBed.configureTestingModule({
        imports: [ReactiveFormsModule, MatDialogModule, UiButtonModule],
        declarations: [NotificationsFormComponent ],
      }).compileComponents();
    })
  );

  beforeEach(() => {
    fixture = TestBed.createComponent(NotificationsFormComponent);
    component = fixture.componentInstance;
    component.urlResolver = jest.fn(url => `http://someSampleUrl.test/${url}`);
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});

Here is the error thrown:

Unexpected value 'CommonModule' imported by the module 'UiButtonModule'. Please add an @NgModule annotation.

Aucun commentaire:

Enregistrer un commentaire