angular - 将 Angular 从 4.0.0-beta.5 升级到 4.0.0 会中断动画和单元测试

标签 angular

我已将我的应用程序中的 Angular 包从 4.0.0-beta.5 升级到 4.0.0,当我运行单元测试时看到以下错误:

Error: Found the synthetic property @transition. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.

然后我安装了@angular/animations 4.0.0 并在我使用动画时将 BrowserAnimationsModule 包含在应用程序模块中。

现在我注意到动画有效,但测试失败并出现相同的错误。

如有任何帮助,我们将不胜感激。

最佳答案

我发现了问题,一些测试使用的是 angular Testbed

import { BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';

TestBed.configureTestingModule({
   imports: [
      RouterTestingModule,
      ...,
      BrowserAnimationsModule // Added this or NoopAnimationsModule** to fix it 
   ]

NOTE**: you can also use NoopAnimationsModule instead if you don't want animations in your tests which is typically the case

关于angular - 将 Angular 从 4.0.0-beta.5 升级到 4.0.0 会中断动画和单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43505656/

相关文章:

html - Angular 4 + Primeng(数据表): custom scrollHeight property

angular - Angular 2子路由会刷新父路由吗

java - 使用来自 angular4 的 @RequestPart 在一个请求中发布多部分文件和 json

typescript - 在动态渲染时更改 Angular 2 中子组件的顺序

angular - Jasmine-core 避免安装 angular-devkit/build-angular

angular - 单元测试 : How do I mock the innerWidth property on the window object with Angular + Jasmine?

angular - 如何以 Angular 查找页面加载时间?

javascript - 如何在 Angular 语法中应用多个 ngIf 条件?

Angular6 表单验证

angular - 禁用表单时,响应式表单有效属性返回 false