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.
我解决了它:) 只需要将节点从 12 升级到 14 即可使其正常工作!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.