2017-08-16 3 views
2

J'ai un projet Ionic2, avec la configuration Unit Testing basée sur le référentiel clicker. J'essaie d'utiliser un bouton d'action flottant dans un composant mais il émet une exception lors de l'exécution des tests unitaires. J'ai ajouté un FAB à l'application clickr simple pour démontrer l'erreur. Il est ajouté à page2.html et vous pouvez le trouver dans le fab-error branch.Comment tester un bouton d'action flottante dans Ionic2

Lors de l'exécution des tests, le journal ressemble à ceci.

> [email protected] test /Users/rkause/test/clicker 
> ng test 

10% building modules 1/1 modules 0 active16 08 2017 12:15:52.892:WARN [karma]: No captured browser, open http://localhost:9876/ 
16 08 2017 12:15:52.902:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/ 
16 08 2017 12:15:52.902:INFO [launcher]: Launching browser ChromeNoSandbox with unlimited concurrency 
16 08 2017 12:15:52.915:INFO [launcher]: Starting browser Chrome 

WARNING in ./~/ionic-angular/util/ng-module-loader.js 
54:11-36 Critical dependency: the request of a dependency is an expression 

WARNING in ./~/ionic-angular/util/ng-module-loader.js 
69:11-36 Critical dependency: the request of a dependency is an expression 
16 08 2017 12:16:02.325:WARN [karma]: No captured browser, open http://localhost:9876/ 
16 08 2017 12:16:02.541:INFO [Chrome 60.0.3112 (Mac OS X 10.11.6)]: Connected on socket djJaMpA7zKcR5c3jAAAA with id 17408513 
Chrome 60.0.3112 (Mac OS X 10.11.6) Pages: Page2 should create page2 FAILED 
    TypeError: unRegEvent is not a function 
     at http://localhost:9876/_karma_webpack_/vendor.bundle.js:41527:13 
     at Array.forEach (<anonymous>) 
     at UIEventManager.webpackJsonp.../../../../ionic-angular/gestures/ui-event-manager.js.UIEventManager.unlistenAll (http://localhost:9876/_karma_webpack_/vendor.bundle.js:41526:19) 
     at UIEventManager.webpackJsonp.../../../../ionic-angular/gestures/ui-event-manager.js.UIEventManager.destroy (http://localhost:9876/_karma_webpack_/vendor.bundle.js:41535:14) 
     at FabContainer.webpackJsonp.../../../../ionic-angular/components/fab/fab-container.js.FabContainer.ngOnDestroy (http://localhost:9876/_karma_webpack_/vendor.bundle.js:9287:22) 
     at callProviderLifecycles (http://localhost:9876/_karma_webpack_/vendor.bundle.js:120688:18) 
     at callElementProvidersLifecycles (http://localhost:9876/_karma_webpack_/vendor.bundle.js:120657:13) 
     at callLifecycleHooksChildrenFirst (http://localhost:9876/_karma_webpack_/vendor.bundle.js:120641:17) 
     at destroyView (http://localhost:9876/_karma_webpack_/vendor.bundle.js:121902:5) 
     at callViewAction (http://localhost:9876/_karma_webpack_/vendor.bundle.js:122048:13) 
Chrome 60.0.3112 (Mac OS X 10.11.6): Executed 14 of 30 (1 FAILED) (0 secs/2.319 secs) 
Chrome 60.0.3112 (Mac OS X 10.11.6) Pages: Page2 should create page2 FAILED 
    TypeError: unRegEvent is not a function 
     at http://localhost:9876/_karma_webpack_/vendor.bundle.js:41527:13 
     at Array.forEach (<anonymous>) 
     at UIEventManager.webpackJsonp.../../../../ionic-angular/gestures/ui-event-manager.js.UIEventManager.unlistenAll (http://localhost:9876/_karma_webpack_/vendor.bundle.js:41526:19) 
     at UIEventManager.webpackJsonp.../../../../ionic-angular/gestures/ui-event-manager.js.UIEventManager.destroy (http://localhost:9876/_karma_webpack_/vendor.bundle.js:41535:14) 
     at FabContainer.webpackJsonp.../../../../ionic-angular/components/fab/fab-container.js.FabContainer.ngOnDestroy (http://localhost:9876/_karma_webpack_/vendor.bundle.js:9287:22) 
     at callProviderLifecycles (http://localhost:9876/_karma_webpack_/vendor.bundle.js:120688:18) 
     at callElementProvidersLifecycles (http://localhost:9876/_karma_webpack_/vendor.bundle.js:120657:13) 
     at callLifecycleHooksChildrenFirst (http://localhost:9876/_karma_webpack_/vendor.bundle.js:120641:17) 
     at destroyView (http://localhost:9876/_karma_webpack_/vendor.bundle.js:121902:5) 
ERROR: 'Error during cleanup of component', Page2{title: 'Page 2', OK: function() { ... }, alertController: Object{create: function() { ... }}} 

J'ai essayé d'ajouter les composants à la main, en se moquant de divers services, mais je n'ai pas pu comprendre ce qui provoque ce comportement. Ionic-mocks La plate-forme maquette définit Platform.registerListener, mais n'a pas de signature pour la fonction.

Répondre