Edit2 :更具体地说,使用像Material Button这样的东西可以正常工作。但是,Side Nav无法与下面的设置一起使用。
编辑:我做了更多测试,发现这与Angular Material特别相关,因为没有它就不会发生这些错误。我仍然不确定如何解决它。
我正在尝试为新组件设置一些基本测试,但是在出错后我一直遇到错误。具体来说,在将@ angular / material添加到项目之后。目前的错误是:
Error: Found the synthetic listener @transform.start. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.
对我来说,感觉像是一只红鲱鱼。
以下是规范:
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { MatSidenavModule } from '@angular/material/sidenav';
import { AngularNavigationComponent } from './angular-navigation.component';
describe('AngularNavigationComponent', () => {
let component: AngularNavigationComponent;
let fixture: ComponentFixture<AngularNavigationComponent>;
beforeEach(
async(() => {
TestBed.configureTestingModule({
declarations: [AngularNavigationComponent],
imports: [RouterTestingModule, MatSidenavModule]
}).compileComponents();
})
);
beforeEach(() => {
fixture = TestBed.createComponent(AngularNavigationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
这是组件
import { Component, OnInit } from '@angular/core';
import { MatSidenavModule } from '@angular/material/sidenav';
import { RouterLink } from '@angular/router';
@Component({
selector: 'mysupercustomcat-navigation',
templateUrl: './angular-navigation.component.html',
styleUrls: ['./angular-navigation.component.scss']
})
export class AngularNavigationComponent implements OnInit {
constructor() {}
ngOnInit() {}
}
任何人都可以告诉我我做错了什么,也可以解释Testbed配置区域中的声明与导入?
编辑:如果重要,这是一个混合应用