Skip to content

Child state with blank URL leading to 404 warning on Karma-Jasmine tests #1430

Closed
@igorauad

Description

@igorauad

I have the following $stateProvider configuration, in which I use an abstract state main.profile resolving a resource that its child states (e.g. main.profile.view) inherit and use. I've noticed that, when running Jasmine unit tests on Karma, due to the fact the url: '' on main.profile.view state, I see a series of 404 warnings, as copied below:

.state('main.profile', {
            abstract: true,
            url: '/:username',
            resolve: {
                usersResource: 'Users',
                user: function(usersResource, $stateParams){
                    var username = $stateParams.username;
                    return usersResource.get({username: username}).$promise;
                }
            },
            controller: 'ProfileViewCtrl',
            templateUrl: 'public/modules/pro/views/profileContainer.client.view.html'           
        })      
        .state('main.profile.view', {
            url: '',
            templateUrl: 'public/modules/pro/views/view.client.view.html',
            onEnter: function(user){
                this.title = user.displayName;
            }       
        })
        .state('main.profile.work', {
            url: '/work',
            templateUrl: 'public/modules/pro/views/portfolio.client.view.html',
            onEnter: function(user) {
                this.title = 'Porfólio de ' + user.displayName;
            }
        })

404 warnings:

WARN [web-server]: 404: /public/modules/main/views/container.client.view.html
WARN [web-server]: 404: /public/modules/pro/views/profileContainer.client.view.html
WARN [web-server]: 404: /public/modules/pro/views/view.client.view.html
WARN [web-server]: 404: /users/context.html
WARN [web-server]: 404: /public/modules/core/views/404.client.view.html
WARN [web-server]: 404: /public/modules/core/views/404.client.view.html
WARN [web-server]: 404: /public/modules/core/views/404.client.view.html

The last three 404 warnings are due to an 404 interceptor configured on $httpProvider.

Did anybody have a similar problem and managed to solve?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions