我已将我的应用程序中的 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/