Tagged Questions
0
votes
3answers
27 views
Unknown provider: $scopeProvider <- $scope
I am trying to make a small test work that validates wether the controller is defined.
The error I am receiving is:
myApp.orders module Order controller should .... FAILED
Error: [$injector:...
3
votes
0answers
29 views
How do I test view that uses controllerAs in AngularJS
I'm trying to test view of my controller but I cannot get this to work.
When I try simple template as<h1>test</h1> it works but when template is using controllerAs syntax I get Expected ...
0
votes
0answers
29 views
Call on $state.go not working in unit test
I work on an app based on Angular 1.5, angular-ui-router and WebPack for which I want to make unit tests on module declaration part, especially on state configuration (I want to test source code of ...
0
votes
0answers
17 views
How to write Jasmine test for Jquery code
I am new to Jasmine test writing. I have below function which I want to test using jasmine test. I am not sure how to check for is() function of Jquery in jasmine test.
toggleNavigationCollapseState(...
0
votes
0answers
14 views
how to unit test an angular directive that binds to scroll
I have an angular directive that returns the scroll top attribute of the element on the scroll event, but I'm having some problems unit testing it.
How do I mock a scroll event so that the scrollTop ...
-1
votes
0answers
8 views
ngMock: $rootElementProvider.$get is not a function
Here's the code
provider
agular.module('myModule', [])
.provider('myEntity', function () {
this.$get = function () {
return {
get id() {
return $...
1
vote
1answer
19 views
protractor deprecated getLocationAbsUr
I am trying to write a code for tasting that I'm redirected to the index.html file using protractor .When I type in terminal protractor protractor.conf.js to execute the e2e tests. it shows me this ...
0
votes
0answers
14 views
Unit test service method called from an anonymous component controller function in Angular
After 3 days of research I'm trying to put the pieces of the puzzle together but with no success. I'm trying to unit test a component's controller and be sure the service injected to it assigns the ...
0
votes
0answers
22 views
How to test a $uibModal instance controller?
I'm trying to test a certain controller functionality with Jasmine unit testing.
I have a function which opens a modal instance with a new controller:
function openFilterModal(data) {
var ...
0
votes
2answers
29 views
AngularJS/Karma/Jasmine - Service call not returning value
I'm attempting to make a call to a Github API using a service injected into a component - and yes, I am using AngularJS 1.5.3.
In the unit test, I am not receiving back a value (the function does ...
0
votes
0answers
9 views
Karma unit tests for Ionic App failing - undefined is not a constructor
I'm completely new to Karma unit testing. I've written an app using the Ionic framework and am trying to write unit tests to test the controllers. I've used the examples from the Angular documentation ...
0
votes
0answers
19 views
Unkown provider: while unit testing AngularJS service
I've been trying to set create an unit test for my service but I haven't been able to figure out how this is supposed to be done.
Whilst Googling on how to do this, I already came across this Stack ...
1
vote
2answers
38 views
How can I test $rootScope.$emit event?
I have below code in abc controller:
$rootScope.$on('selectedItem', function (event, data) {
vm.selectedItem = data;
});
And the caller function is in xyz controller:
function doThis(...
0
votes
2answers
14 views
Unit test controller, angularJS and jasmine
Hi I've been trying to unit test basic functions in my controller however I can't seem to connect when setting up the unit test.
Error: [$injector:modulerr] Failed to instantiate module myApp due to:
...
0
votes
1answer
24 views
Test post service jasmine karma angular js
I new to Unit testing and trying to run the test cases but always getting an error Unexpected request POST service
Below is my code
angular service
angular
.module('testModule')
.factory('...
0
votes
1answer
16 views
How to test AngularJS component that use promise?
I have the following component that I want to unit test.
myApp.component('myComponent', {
controller: function($q) {
let serviceDummy = $q((resolve, reject) => resolve(42));
this.number =...
0
votes
2answers
25 views
Karma jasmine Angular 1.6.2 testing filter throws error Uncaught Error: [$injector:unpr]
I am working on testing my AngularJS code, and I am having a problem that all the answers I could find wouldn't fix.
I am trying to test a filter that looks like this:
app.filter('capitalize', ...
1
vote
0answers
18 views
How to unit test angular material md datepicker?
How can I test how to manually open an angular material directive for unit testing?
<div layout-gt-xs="row">
<div class="col-md-12">
<md-...
1
vote
1answer
44 views
How can I unit test the result of a ui-bootsrap $uibModal instance?
I have a controller that calls $uibModal.open to pop a ui-bootstrap modal. The controller looks like this:
(function () {
'use strict';
angular
.module('app')
.controller('...
0
votes
0answers
22 views
Is it possible to write a mock service for a stateful AngularJS component?
I have an AngularJS component that gets data from a custom service, which has a dependency on $http service. Mocking services doesn't seem to be as straight forward in Components as it is in regular ...
0
votes
1answer
19 views
angularjs unit testing (cannot find propery of 'resolve' undefined angularjs testing)
I am trying to do unit test of my angular app with karma. I am getting some error. Am i missing something? A
This my controller
(function () {
"use strict"
angular
.module("myApp")
.controller("...
1
vote
1answer
28 views
When migrating from Angular 1.5 to 1.6 routing is ran inside unit tests
I've migrated my app to Angular 1.6 and suddenly unit test aren't working anymore. After investigating a little I found out that routing is enabled when running unit tests.
The code that I have added ...
0
votes
1answer
19 views
Unit testing ngComponentRouter - Angular 1.5.x
I am trying to build basic unit tests for an Angular 1.5 with the purpose of A) practicing unit testing, and B) familiarizing myself with component-based development in Angular 1.5.x. I'm trying to ...
1
vote
0answers
37 views
How to unit test a Angular Filter that uses a function from a Service?
I am using Jasmine to unit test my Angular project.
I succesfully unit tested a filter without any dependencies.
But how would i test a filter/controller/service that uses functions from other ...
0
votes
0answers
18 views
Unit Testing Angular 1.5 component that requires ngModel
To test angular 1.5 components, the docs recommend you use ngMock's $componentController instead of using $compile if you don't need to test any of the DOM.
However, my component uses ngModel which I ...
0
votes
1answer
74 views
$compile doesn't insert scope variable into the HTML
I want to test the rendering of an HTML with my scope variable inside my unit test.
HTML has 2 <textarea> which are as follows:
<textarea ng-model="a" ng-change="someFunction(a)" value={{a}}...
0
votes
0answers
11 views
Undefined is not a constructor on event stateChangeSuccess with PhantomJs / Mocha
I'm trying to setup Continuous Integration. For this I need to use PhantomJS instead of Chrome.
When I tun my unit test with Chrome, everything is working but when I do the same with PhantomJS, I ...
1
vote
0answers
18 views
How to run Jasmine JS in ReSharper?
I started out with a .NET 4.5 solution in VS2015, with the latest ReSharper plugin. I followed this tutorial:
https://blogs.endjin.com/2014/09/unit-testing-angularjs-with-visual-studio-resharper-and-...
2
votes
0answers
53 views
Angular 2 unit test doesn't wait for promise to return
I have the following component method:
onSignup() {
if (this.form.valid) {
let email = this.form.value.email;
let password = this.form.value.password;
this.usersService.signup(...
0
votes
1answer
21 views
Angularjs Jasmine unit testing a controller : $scope and ionicPopupProvider is undefined
I'm trying to test my simple controller but seems like nothing is working.
the controller:
userCtrlMod.controller('resetCtrl',
['$scope', '$ionicPopup', '$timeout','resetPwd',
function($scope, $...
0
votes
1answer
54 views
AngularJS - Controller not registered
I am starting out on AngularJS Unit Testing and I am getting an error like Controller with name "SiteCtrl" is not registered.
What I am doing wrong here?
describe('#hasFormError', function () {
...
0
votes
0answers
12 views
How can I unit test a factory WITHOUT a controller? Angularjs/ngMocks
Every example I've run across when unit testing involves a controller.
I have unit tests within the controller but they are just testing that the service method is called when I expect it to. I ...
1
vote
1answer
24 views
unit test this.$onDestroy in angular>1.5 / es6
using angular 1.5 / es6, I have the following code that I want to test :
this.$onDestroy = function () {
this.$interval.cancel(someIntervalTimer);
};
I cant find out how to trigger ...
0
votes
1answer
32 views
How to test controller with template provided by state from ui-router
Configuration for ui router:
$stateProvider
.state('search', {
url: '/search',
views: {
content: {
templateUrl: 'scripts/search/search-...
1
vote
1answer
72 views
Unit test $mdDialog angular material
I called one $mdDialog inside a function. I want to unit-test $mdDialog ok and cancel cases.
The below is my controller code (app.controller.js).
(function () {
'use strict';
app....
2
votes
1answer
49 views
Angular Mocks Version Relation With Angular's Version
While implementing Karma on an AngularJS application with version 1.3.16, the angular-mocks module throw the following error -
angular-mocks.js:Uncaught TypeError: angular.module(...).info is not a ...
0
votes
1answer
58 views
$injector:unpr Unknown provider error when testing with Jasmine
So the first time of tackling with unit tests here, I'm trying to initialize the controller of a component using the $componentController mock in angular.mocks.
This is my component file.
import ...
0
votes
1answer
24 views
Sinon spy: Attempted to wrap undefined property 'path' as function
The following spy on location.path is failing with an error:
Attempted to wrap undefined property path as function
it('should redirect location.path', function() {
sinon.spy(location, 'path');
...
0
votes
0answers
49 views
Cannot correctly inject angular dependencies when unit testing with karma, jasmine, webpack
I'm trying to unit test my angular.js application which uses webpack,
but I cannot to load the dependencies of angular correctly.
My current controller file is the following (simplified) :
////...
0
votes
0answers
37 views
Module is not available in angularjs + Jasmine Unit testing
Module is defined as
var $manage = angular.module('manage', [....]);
Controller is defined as
$manage.line.events.controller('eventsController', [..., function(...){
$scope.page = "events";
}])...
0
votes
2answers
37 views
How to test angular service with dependencies using jasmine?
I have service that looks like that:
angular.module('app').service('MyService' , function (dependency1, dependency2, dependency3 ...) {
function funcToTest() {
// Do something
}
}
...
0
votes
1answer
30 views
Angular Testing - trigger on change not working
I have a directive that I'm trying to unit test that includes an on 'change' event:
iElement.on 'change', (evt) ->
scope.$apply () ->
scope.model.user.data.roles = ...
0
votes
0answers
10 views
Trouble testing callbacks in Karma.
I'm having trouble mocking catch blocks in promises
SidebarSpotlight.controller.js
function submit() {
promotionsService.submit(vm.spotlightPromotion.Languages[0], vm....
0
votes
1answer
26 views
AngularJs Unit Testing Controller with sweetalert in Jasmine Testing
I'm trying to test my angularjs controller with jasmine and karma but i cant test codeblocks that are in sweetalert function. How can i confirm sweet function from my test class to test $scope....
1
vote
1answer
35 views
Testing a public value that is set in the then of a $q.all() in Angularjs 1.6
I'm trying to test an angular component using $componentController
I'm only trying to test inputs and outputs of public code, so in my controller the "this.data" property is highest priority. Starting ...
0
votes
1answer
17 views
When unit testing a directive how to pass its controller
I am new to AngularJS and its unit test. Currently I am trying to test a directive with its controller in the template file:
It's template:
<div ng-controller = "SomeController" >
<select ...
0
votes
2answers
42 views
How to mock $http.post method that has been called in other service method in jasmine?
I have and angular service that I want to test. In one of his methods I am using $http of angular service. I am simply want to mock that function (to be more specific mock $http.post function) that ...
0
votes
2answers
24 views
Error testing Angular services with Jasmine/Chutzpah
I'm trying to test my AngularJs services using Jasmine but I keep getting all kinds of errors.
So I tried to create a very basic Sum service to test it and the errors keep on coming.
This is the ...
0
votes
1answer
15 views
Trying to do a unit test for a controller with $state
I am trying to write some unit tests for my Angular 1.5 components based on this tutorial.
import notificationBannerTemplate from 'app/components/notification-banner/notification-banner.html';
...
0
votes
1answer
43 views
Unit testing $q promise within Angular service - Karma, Jasmine
I am trying to unit test an Angular service with Karma and Jasmine. I'm making I've seen a number of tutorials on how to unit test a service call from a controller, but I wish to unit test within the ...