更新到Angular 4.0.0后,我的测试失败
Error: Found the synthetic property @visibilityChanged. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application. in config/karma-test-shim.js (line 82476)
ZoneAwareError@webpack:///~/zone.js/dist/zone.js:923:0 <- config/karma-test-shim.js:82476:28
checkNoSyntheticProp@webpack:///~/@angular/platform-browser/@angular/platform-browser.es5.js:2945:0 <- config/karma-test-shim.js:17836:24
在karma-test-shim.js中试过这种方法来修复但是没有用
Error.stackTraceLimit = Infinity;
require('core-js/es6');
require('core-js/es7/reflect');
require('zone.js/dist/zone');
require('zone.js/dist/long-stack-trace-zone');
require('zone.js/dist/proxy');
require('zone.js/dist/sync-test');
require('zone.js/dist/jasmine-patch');
require('zone.js/dist/async-test');
require('zone.js/dist/fake-async-test');
var appContext = require.context('../src', true, /\.spec\.ts/);
appContext.keys().forEach(appContext);
var testing = require('@angular/core/testing');
var browser = require('@angular/platform-browser-dynamic/testing');
var animation = require('@angular/platform-browser/animations');
testing.TestBed.initTestEnvironment(
browser.BrowserDynamicTestingModule,
browser.platformBrowserDynamicTesting(),
animation.BrowserAnimationsModule
);
答案 0 :(得分:0)
将BrowserAnimationsModule
添加到您的项目ngModule
并添加import
,如下所示:
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
.....