2017-05-31 107 views
0

我的測試中被更新到4.0.0角角4 - 失敗測試導入brosweranimations模塊

Error: Found the synthetic property @visibilityChanged. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application. in config/karma-test-shim.js (line 82476) 
[email protected]:///~/zone.js/dist/zone.js:923:0 <- config/karma-test-shim.js:82476:28 
[email protected]:///~/@angular/platform-browser/@angular/platform-browser.es5.js:2945:0 <- config/karma-test-shim.js:17836:24 

試圖在卡瑪測試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 
); 
+1

一定的T他:我必須在導入spec.ts文件中包含BrowserAnimationsModule,而不是在karma-test-shim.js中 –

回答

0

添加BrowserAnimationsModule到項目ngModule並添加import也象下面這樣:

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

@NgModule({ 
    imports: [ 
    BrowserModule, 
    BrowserAnimationsModule, 
.....