Tagged Questions
0
votes
0answers
56 views
UI-Router Unit testing for a state to be redirected, receiving 'error: transition superseded'
I'm attempting to unit test the following AngularJS run function:
export default function run($rootScope, auth0Service, $state, lock) {
$rootScope.$on('$stateChangeStart', function(event, ...
8
votes
2answers
6k views
AngularJS and UI-Router: 'Error: transition superseded' during angularjs unit tests
I'm attempting to create an authorization package for a project of mine. I'm getting the error 'transition superseded' during my unit tests, and I can't find out where that would actually be.
Unit ...
0
votes
1answer
44 views
Unable to Unit Test an Angular Controller with service mocked
I'm starting with angularJs and I'm facing an issue when trying to unit test a controller that have a dependency to a service. The application worked as expected but not the unit test.
I obtain the ...
0
votes
2answers
119 views
How to test Angularjs route's resolve value on component?
I'm using [email protected] and resolve some resource at the route level for one of my component. The component works as expected but my test fails now.
Error
PhantomJS 2.1.1 (Linux 0.0.0) module ag....
2
votes
0answers
57 views
Unknown provider: $stateProviderProvider in ui router testing
I'm trying to write test case for the Router in my angular app.I'm using "angular-ui-router": "0.3.1",
Below is the setup and a sample test case :
beforeEach(angular.mock.module("ui.router"));
...
0
votes
0answers
51 views
Angular Unit testing : $location in HTML5 mode requires a </path/to/my/app> tag to be present
I am using Karma to write my test scripts and here is my karma.conf.js code
'use strict';
/**
* Module dependencies.
*/
var _ = require('lodash'),
karmaReporters = ['spec', '...
0
votes
0answers
35 views
Angular reloading page every $digest cycle
I have an angular app with ui-router and I writing my unit tests using jasmine.
State for the / URL which performs a resolve to have some data available in the controller.
$stateProvider
....
0
votes
2answers
70 views
Why isn't $injector finding $state in my unit test?
The following is my module and unit test set-up. When I try to set $state, $injector.get("$state") throws the always fun Unknown provider: $stateProvider <- $state error and I don't understand why. ...
0
votes
1answer
59 views
Stubbing factory being used in resolve
I'm trying to unit test my states in an controller. What I want to do is stub out my items factory, since I have separate unit tests that cover that functionality. I'm having a hard time getting the $...
1
vote
1answer
64 views
How to unit test statetransition in angular?
I am getting my head around unit test with karma. I want to check the state transitions so I created this test. The app starts off with going to the landing state and from there I want to go to main. ...
0
votes
0answers
30 views
how write unit test case for $stateProvider.init() using jasmine in angularjs
I'm unable to mock the $stateProvider.init() function in my unit test file
Here i'm giving original library file angular-ui-router.js file, and when i'm run the spec file while executing $...
0
votes
0answers
17 views
Unit testing child state dependant on parent resolve to be completed first
I am trying to unit test a resolve function of a state that is the child of an abstract state.
The abstract state also has a resolve on and I require the abstract state resolve to be completed before ...
0
votes
0answers
44 views
Angular UI-router interferes with $http.get promise when unit testing factory service
I'm fairly new to Angular and trying to unit test a very simple $http GET request (Karma with mocha/chai/sinon) within a factory. I'm using the ui-router module, which, based on UI-router interfers ...
0
votes
0answers
45 views
Unit Test UI Router decoration config
I am trying to unit test if my module is correctly decorated:
Here is my decorator:
angular.module('myRouteDecorator', [
'ui.router',
'myService'
]) .config(function($stateProvider){
$...
2
votes
1answer
557 views
Injecting mock $state into an angular unit test
I'm a relative weakling at Angular unit testing and I'm struggling mightily to bootstrap what strikes me as a simple unit test.
My Class
class CampaignController {
constructor($state) {
...
4
votes
3answers
1k views
angularJS $stateProvider : How to unit test different views in UI-Router?
How can I unit test different views for the below scenario
.state('app.sr.product.upload', {
name: 'upload',
url: '/upload',
data: {
tags: [],
...
0
votes
1answer
52 views
Setting up and testing UI Router
I'm trying to use ncy-angular-breadcrumb, which uses ui routes. I have a module set up to house the ui routes:
(function () {
var app = angular.module('configurator.uiroutes', ['ui.router', 'ncy-...
0
votes
0answers
66 views
Karma unit test controller becomes undefined after adding resolver in ui-router
In the configure.js:
$stateProvider.state('home', {
url: '/',
views: {
'nav-menu': {
templateUrl: '/views/nav-menu.ng',
controller: 'myApp....
0
votes
1answer
408 views
angular ui-router test state
I'm writing up a series of unit tests for a login module. Right now, all the failures are being applied as expected. However, I'm having an issue testing a valid login because the test is returning ...
1
vote
1answer
188 views
How can I trigger ui-sref in an AngularJS unit test? [duplicate]
I'm testing an AngularJS view. There are a few non-standard helpers in this code sample, but hopefully it will get the point across. I'm fairly certain none of them are interfering with the function ...
0
votes
0answers
147 views
Missing angular-ui-router states in AngularJS unit test
I am trying to test the routes defined for the angular-ui-router of my AngularJS application. The test is using a karma / jasmine setup. I am injecting the $state service in the test in order to check ...
3
votes
1answer
173 views
Otherwise on $urlRouterProvider redirects to a state when it shouldn't in unit tests
I use ui-router in my code and here is how I define states in my application:
$stateProvider
.state('base', {
url: '/',
templateUrl: '../views/base.html',
...
0
votes
0answers
1k views
Expected spy go to have been called with [ 'stateName' ] but it was never called?
This is working fine:
spyOn($state, 'go');
But when I execute below line its not working and giving this error:
'Expected spy go to have been called with [ 'stateName' ] but it was
never called'
...
1
vote
0answers
166 views
Unit test onEnter with ui-router
I have a state onEnter block like the following. I'm trying to do a redirect based on data.length.
.state('home', {
url: '/',
data: {
title: 'Home',
},
controller: 'HomeCtrl ...
1
vote
1answer
97 views
Trouble testing state transition in ui-router
I'm trying to write a test for an Angular app using ui-router similar to that suggested by http://stackoverflow.com/a/21078955/270511.
it('should transition to state', inject(function($rootScope, $...
1
vote
1answer
42 views
How I'm supposed to run unit test for angular ui-router
I'm quite new with karma...
I want to contribute with a bug fixing for angular ui-router.
I need to write new unit tests and check all the other tests but I don't understand how I'm supposed to run ...
0
votes
3answers
111 views
UI Router resolve throws Unexpected Get request in Angular
I'm using UI router and define a site-wide resolve.
$stateProvider
.state('site', {
abstract: true,
resolve: {
exampleResolve: function(MyApiService) {
return MyApiService.get(...
1
vote
1answer
602 views
Unit testing controller with injected dependencies
What is the best practice to inject the dependencies into my
controller test?
When would I use the module(function($provide){})?
How do I properly check that $state.go() was called with the right ...
1
vote
2answers
67 views
Unit testing $http resolve in controller
I need help with my controller test. I have a resolve using ui-router. In my test, I need to figure out how to handle the resolve's exampleData.
config.js
angular.module('myModule')
.config(['$...
1
vote
0answers
377 views
Testing default state for Angularjs ui-Router in karma-mocha
I want to write test a in karma for checking default state. How can I set a wrong URL for UI-Router?
JS file:
app.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('...
2
votes
2answers
799 views
angular empty $state name when testing routing with jasmine
Like many folks, I'm new to testing Angular with Jasmine and am struggling to get this right. I use ui-router to do my routing and right now, the problem I'm having is that the $state.current.name in ...
0
votes
1answer
859 views
how to construct unit test for controller with $state?
Trying to write a unit test for my controller:
app.controller('StartGameCtrl', function ($scope, $timeout,$state) {
$scope.startGame = function () {
$scope.snap = false;
$scope....
5
votes
1answer
708 views
Testing stateProvider state if configured in config in angularJS returns null on $state
I have a config like this one:
angular.module('myModule', ['ui.router'])
.config(['$stateProvider', function($stateProvider) {
$stateProvider
.state('app.home', {
abstract: true,
...
1
vote
1answer
2k views
How can I mock ui-router's resolve values when testing a state's configuration?
I'm writing an angular application using ui-router and I'm looking to write tests for my ui-router configuration.
Specifically, I'm looking to test my onEnter and onExit callbacks bound to a state. ...
2
votes
1answer
1k views
Get current controller instance in UI-Router? (in tests)
I setup a test for a route based on this answer. I now want to check if things injected to the route's controller are setup correctly. From the state object, I can only get the controller's ...
3
votes
1answer
3k views
Testing ui.router $stateChangeSuccess
I have a simple function in my main controller that updates $scope.loading based on ui.router's $stateChangeStart and $stateChangeSuccess events.
$scope.$on('$stateChangeStart', function(event, ...
0
votes
0answers
753 views
How to inject $state correctly for angular ui router unit tests?
I am trying to write Unit-Tests for the following use case:
A http-request responds with an unathorized http-status(401) -> change state to login
The Problem is, that I dont even get the correct $...
2
votes
1answer
611 views
Angular ui router set current state in unit test
I have this simple snippet of code (the real app code is more complicated), the point is to test $state.includes
$scope.Testing (state) {
if (!$state.includes(state)){
$state.go(state);
}...
0
votes
1answer
319 views
How to unit test onEnter and resolve of ui-router state
I'm trying to test an Angular UI Bootstrap modal that is being called from the onEnter of the following state:
.state("profile.index.edit.services", {
url: "/edit/services/:serviceCode",
...
2
votes
1answer
2k views
angular unit test state change with resolve
Scenario
I have built search form with 2 states:
First state triggers the second one (onclick), and sets some state parameters with $state.go() function.
Second state has resolve function which ...
3
votes
0answers
389 views
Angular UI-Router verify onEnter in test
I am in the middle of writing some tests for my application (AngularJS).
As we speak I encountered a problem with verifying if onEnter property of my state was called correctly.
Let me share some ...
6
votes
4answers
2k views
UI Router Extras breaks my unit tests with unexpected results error?
QUESTION:
- Why are my tests failing when ui-router-extras (not normal ui-router) is install?
- How can I use ui-router-extras and still have my tests pass?
If you want to install this quickly use ...
2
votes
2answers
1k views
Setting the path in ui-router via $location.path() does not change $state.current
I am initializing my angular controller with the following code:
console.log($state.current);
$location.path('/newpath');
console.log($state.current);
The $state.current variable is not being ...
0
votes
2answers
508 views
Getting “Unexpected request” error when running Karma unit test in an AngularJS app
I have seen some questions regarding this but all of them was specific to each case and I couldn't find a solution for my case in those posts.
I have a current controller:
function Login(...
1
vote
1answer
112 views
Testing a service that depends on $state
I've been trying to write a unit test for my Progress Service, which manages the different states of a flow (jumps to next incomplete step, marks step as complete, etc.)
I'm trying to configure $...
1
vote
1answer
609 views
Angular test ui-router custom inline controller
I'm trying to figure out a way to test one my routes that has a really custom behavior. Here is the code of the state :
$stateProvider.state('oauth', {
url: '/oauth/callback',
controller: ...
0
votes
0answers
250 views
Testing angular ui-router state urls
Trying to write just the most basic tests for a ui-router and running into some issues. I have referred to Angular ui router unit testing (states to urls) and a related blog post http://bardo.io/...
5
votes
2answers
472 views
AngularJS- unit testing an anonymous controller
I'm trying to write tests for code that I didn't write that uses ui-router.
I can't figure out a way to inject a controller into my test since it is written inline and anonymously within a state ...
1
vote
1answer
537 views
Unit testing $urlRouterProvider.otherwise in provider config
So i've got my code:
(function (ng) {
ng.module('myModuleName')
.provider('myProviderName', ['importedThing', function (importedThing) {
//lots of cool stuff happens in here
...
2
votes
0answers
2k views
How can I test angular ui-router $stateChangeStart listeners?
Here's a basic authentication scheme I'm using in angular. I'm trying to unit test this little chunk that listens for state changes and checks both if they need authentication and if the user is ...