nglink not working in phantomjs component test for angular 1.5

260 Views Asked by At

I have a navbar component:

.component('navbar', {
      templateUrl: 'app/common/navbar/navbar.html',
      controller: NavbarController,
      bindings: {
        state: '<',
        weekLabel: '<'
      }
    })

  /** @ngInject */
  function NavbarController () {
  }
<div class="header">
  <h3 class="text-muted">
    Vaccine Stock Dashboard
    <span ng-if="$ctrl.state"> - </span>
    <span class="qa-state-label" ng-bind="$ctrl.state | uppercase"></span>
    <span ng-if="$ctrl.weekLabel"> - </span>
    <span class="qa-week-label" ng-bind="$ctrl.weekLabel"></span>
    <a class="pull-right" ng-link="['NewStockCount']">
      <i class="fa fa-plus"></i>
      Add Stock Count
    </a>
  </h3>
</div>

The test runs fine without the ng-link="['NewStockCount']" but if i add it fails with an error

ReferenceError: Can't find variable: Map (line 2166) RouteRegistry@/home/femi/fielded/nav-integrated-state-dashboard/bower_components/bower-angular-router/angular1/angular_1_router.js:2166:30

how do i correct this to make it pass with ng-link

2

There are 2 best solutions below

0
On BEST ANSWER

Well after my search i realized it wasn't my code that have the issue but Phantomjs is not compatible with es6 yet. the solutions is to either bump up to Phantomjs2 or add polyfills; here is a fantastic article on that

2
On

According to the documention for the component router, the directive is router-link, not ng-link (even though it's called ngLink).