Skip to content

Error with unit testing #263

@davitykale-zz

Description

@davitykale-zz

I'm working on an Angular app that uses Angular UI-Router for routing and maintaining state. I am having a hard time getting my unit test to even compile. I've checked out the other GitHub issues relating to ui-router and unit testing, and nothing seems to help. It seems that no matter what I do, I keep getting the following error:

Error: State '' is not navigable

I have the following states set up in my app, as well as the following redirects:

app.config(function($stateProvider, $urlRouterProvider) {

var paramList = '?beds&lat&lon&zoom';

$urlRouterProvider
    .when('', '/')
    .when('/', '/search')
    .when('/search', '/search/list')
    .otherwise('');

$stateProvider
    .state('search', {
        abstract: true,
        url: '/search',
        templateUrl: 'views/search.html',
        controller: 'SearchCtrl'
     })
        .state('search.list', {
            url: '/list' + paramList,
            templateUrl: 'views/search-list.html'
         })
        .state('search.map', {
            url: '/map' + paramList,
            templateUrl: 'views/search-map.html'
        })
    .state('search.listing', {
        url: '/listing/:id' + paramList,
        templateUrl: 'views/search-listing.html'
    })
    .state('favorites', {
        url: '/favorites',
        templateUrl: 'views/favorites.html'
    })
});

I've eaten up an entire day trying to get a single test to work, but no matter what approach I take, I always end up at this same error. I have an e2e test running just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions