Unit testing ionic modules like ionic popover


I have the following function in my controller:

function setupMenuPopover() {
      $ionicPlatform.ready(function () {
        $ionicPopover.fromTemplateUrl('views/menu-popover.html', {
          scope: $scope
        }).then(function (popover) {
          vm.menuPopover = popover;

How can I test this with karma?

Currently I have something like:

it('this.setupMenuPopover should setup the menu popover', inject(function(_$ionicPopover_){
      var popup = spyOn(_$ionicPopover_, 'fromTemplateUrl').and.callThrough();

      //expect(HomeController.menuPopover).not.toBeNull() <-- returns false, while it should be true.

Thanks in advance!


@Brock01 Did you find any solution? Even I am trying to write test case for popover.


This is old but should give you a start:


Thanks. But I want test case for popover.

This is my code

$ionicPopover.fromTemplateUrl('app/contextMenu.html', {
      scope: $scope
    }).then(function (popover) {
      $scope.popover = popover;
    $scope.openPopover = function ($event) {
    $scope.closePopover = function ($event) {
    $scope.$on('$destroy', function () {