Javascript 茉莉花测试材料设计

Javascript 茉莉花测试材料设计,javascript,angular,testing,material-design,angular-material2,Javascript,Angular,Testing,Material Design,Angular Material2,Edit2:更具体地说,使用类似“材质”按钮的功能也可以。然而,侧导航与下面的设置不配合 编辑:我做了更多的测试,发现这与角度材质特别相关,因为没有它这些错误不会发生。我仍然不知道如何修复它 我正试图为一个新组件设置一些基本测试,但我总是一个接一个地出错。特别是在向项目添加@angular/材质后。当前错误为: Error: Found the synthetic listener @transform.start. Please include either "BrowserAnimation

Edit2:更具体地说,使用类似“材质”按钮的功能也可以。然而,侧导航与下面的设置不配合

编辑:我做了更多的测试,发现这与角度材质特别相关,因为没有它这些错误不会发生。我仍然不知道如何修复它

我正试图为一个新组件设置一些基本测试,但我总是一个接一个地出错。特别是在向项目添加@angular/材质后。当前错误为:

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 { NO_ERRORS_SCHEMA } from '@angular/core';
添加到页面顶部,并且:

schemas: [NO_ERRORS_SCHEMA],
在与声明相同的级别添加

这有什么用?这告诉angular不要在未知元素或属性上出错。现在,对于这个用例,这是有效的,因为我对集成测试不太感兴趣。我相信在这种情况下,这可能会造成问题

我对单元测试感兴趣,忽略模板属性对我来说很好。加上这一点,我就达到了这个水平


这个答案是我目前能得到的最完整的。

对我来说就像是一条红鲱鱼??WT?材料需要
BrowserAnimationsModule
NoopAnimationsModule
。在应用程序中添加一个,我已经尝试过了,但是它在@angular/material库中抛出了一个错误,这就是为什么我认为这是一个误导。TypeError:无法读取MatSidenav.ngAfterContentInit……node_modules/@angular/material/esm2015/sidenav.js:327:1处未定义的属性“create”
schemas: [NO_ERRORS_SCHEMA],