2
我目前正在使用angullar-cli的angular2項目。從tomorow開始,我從ng test命令中得到一個新的錯誤,下面的trace。每次運行測試命令時都會觸發此錯誤。我確定spec.ts中的代碼會引發錯誤:Angular2/ng測試錯誤:'未處理的Promise拒絕'
const fakeRouter = jasmine.createSpyObj('Router', ['navigate']);
beforeEach(() => TestBed.configureTestingModule({
imports: [AppModule, RouterTestingModule],
providers: [{ provide: Router, useValue: fakeRouter }]
}));
當我刪除提供程序路由器時,錯誤消失。 但是,我所有的測試都通過了成功。
我的角CLI版本:
角CLI:1.0.0-beta.32.3 節點:6.7.0 操作系統:Win32的64
錯誤:
ERROR: 'Unhandled Promise rejection:', 'Cannot set property 'afterPreactivation' of undefined', '; Zone:', 'ProxyZone', '; Task:', 'Promise.then', '; Value:', TypeError{}, 'TypeError: Cannot set property 'afterPreactivation' of undefined
at http://localhost:9876/base/src/test.ts?10abbba6756b062e1f8ba4c1873d1f257bc67f65:66907:49
at ZoneDelegate.invoke (http://localhost:9876/base/src/test.ts?10abbba6756b062e1f8ba4c1873d1f257bc67f65:94256:26)
at ProxyZoneSpec.onInvoke (http://localhost:9876/base/src/test.ts?10abbba6756b062e1f8ba4c1873d1f257bc67f65:70192:39)
at ZoneDelegate.invoke (http://localhost:9876/base/src/test.ts?10abbba6756b062e1f8ba4c1873d1f257bc67f65:94255:32)
at Zone.run (http://localhost:9876/base/src/test.ts?10abbba6756b062e1f8ba4c1873d1f257bc67f65:94052:43)
at http://localhost:9876/base/src/test.ts?10abbba6756b062e1f8ba4c1873d1f257bc67f65:94605:57
at ZoneDelegate.invokeTask (http://localhost:9876/base/src/test.ts?10abbba6756b062e1f8ba4c1873d1f257bc67f65:94289:31)
at ProxyZoneSpec.onInvokeTask (http://localhost:9876/base/src/test.ts?10abbba6756b062e1f8ba4c1873d1f257bc67f65:70216:39)
at ZoneDelegate.invokeTask (http://localhost:9876/base/src/test.ts?10abbba6756b062e1f8ba4c1873d1f257bc67f65:94288:36)
at Zone.runTask (http://localhost:9876/base/src/test.ts?10abbba6756b062e1f8ba4c1873d1f257bc67f65:94092:47)
at drainMicroTaskQueue (http://localhost:9876/base/src/test.ts?10abbba6756b062e1f8ba4c1873d1f257bc67f65:94455:35)
您是否找到解決方案?我有同樣的問題。 –