Tagged Questions
0
votes
1answer
8 views
How to actually reset $httpBackend expectations?
I've tried and tried to get this to work. The documentation is terse, at best:
resetExpectations(); - Resets all request expectations, but preserves all backend definitions. Typically, you would ...
0
votes
0answers
8 views
Cordova & AngularJS unit testing
I'm currently developing an application based on Cordova (http://cordova.apache.org), deployed on iOS for now.
I've started to write some unit tests using jasmine, as i used to do when i developed a ...
0
votes
0answers
8 views
object and resource comparison error when doing http.get request
I'm confused as how to fix this problem. I'm mocking a http.get request from my service and in my unit test the resource returns identically the same contents as the expected result, except that the ...
0
votes
1answer
26 views
spyOn $scope.$on after $broadcast toHaveBeenCalled fails
I'm having a lot of trouble getting this simple test working.
I've got an $scope.$on listener in a controller that I want to test. I just want to make certain it's called after a broadcast event.
To ...
-4
votes
0answers
12 views
what are some examples of java unit test cases using TestNG_setup to test my business layer code? [on hold]
looking for some reference of good unit testing on business layer.you can share some posts or few examples or experiences.what are some examples of java unit test cases using TestNG_setup to test my ...
0
votes
1answer
22 views
AngularJS unit testing directive with ngModel
I have made a directive which uses ngModel:
.directive('datetimepicker', function () {
return {
restrict: 'E',
require: ['datetimepicker', '?^ngModel'],
controller: ...
0
votes
0answers
17 views
How to evalute the received message status through jasmine spy to an angular controller and evaluating URL redirection process
I have a question regarding using jasmine spy objects to test controllers that depends on a service.Though there were some questions along similar lines they did not provide an answer for my question ...
0
votes
1answer
30 views
AngularJS controller unit test using the “controller as” syntax
I'm having some trouble adapting this test to use the "controller as" syntax. Here's what I have ...
The controller I'm testing is:
function MyCtrl ($scope, someService) {
someService.get()
...
0
votes
1answer
20 views
$rootScope is undefined when testing with Karma
I am trying to write some unit tests for an angular project. I've followed some examples about testing a controller but I always end up with the same problem: $rootScope seems to be undefined.
My ...
0
votes
2answers
16 views
$scope.$on undefined in controller during unit testing
My controller works great. But when I want to test it in karma the $scope.on method comes up as undefined.
Here is my controller:
angular.module('myApp').controller('DataController', [
...
0
votes
1answer
13 views
$httpBackend mock not sending a request?
After too many hours, I cannot for the life of me get this example working. I'm following Ben Lesh's excellent guides to mocking $http requests in Angular, but for some reason the service request is ...
3
votes
1answer
51 views
AngularJS Change Constant Value that gets passed to Config for Unit Test
Is there anyway to change the constant value that gets sent to the config function of the module for a Unit Test?
I have the following (fiddle here):
//--- CODE --------------------------
var module ...
-1
votes
0answers
20 views
how to get jasmine test working?
Just started trying jasmine unittesting and angularjs.
I am getting a reference error:
ReferenceError: browser is not defined in http://run.plnkr.co/spLhS7TjY5NO1w78/appSpec.js (line 11)
the ...
2
votes
1answer
33 views
Protractor E2E - How Do You Manage Database?
I'm currently leaning on the Node + Angular stack and utilising Karma and Protractor for testing.
I'm currently having a hard time figuring out how to handle E2E tests that create and edit data, as ...
0
votes
1answer
21 views
Jasmine 2.0 async done() and angular-mocks inject() in same test it()
My usual test case looks like
it("should send get request", inject(function(someServices) {
//some test
}));
And Jasmine 2.0 async test should look like
it("should send get request", ...
0
votes
0answers
17 views
AngularJS unit testing error when using clientWidth
In my code there's a line:
var contentWidth = angular.element(document.querySelector('.content'))[0].clientWidth;
It works fine when running the app but when unit testing I get error:
TypeError: ...
0
votes
1answer
27 views
Unit-testing slider directive with AngularJS + Jasmine
I am a newbie to both Angularjs and unit-testing with jasmine, so iI hope this makes sense and is correct enough to get an answer :)
I am trying to test an angularJS directive that creates sliders ...
0
votes
0answers
9 views
Expected spy to be called error at null<anonymous>
i'm totally lost on what to do. I have googled all possible ideas to test if my method was called, but no luck so far. All i want to do is check if my method has been called.
this is my test script
...
0
votes
1answer
28 views
how to test $scope.method inside a controller?
I've tried using Spies, tried declaring a variable by calling the function and nothing works.I 'm new to unit testing and i must be misunderstanding something
my unit test for the function
...
0
votes
1answer
17 views
how to check if methods have been called jasmine unit test
I'm new to unit testing, and after reading the docs I'm still confused on how to do checks on asynchronous methods, as far as i understand I will need to use runs() and wait(). However, instead of ...
0
votes
1answer
16 views
karma.conf.js uncaught referencerror: google no defined
when i try running the karma test runner, i'm getting a error as the following from one of my files, saying that my library google is undefined???
Chrome 36.0.1985 (Mac OS X 10.9.4) ERROR
...
1
vote
1answer
21 views
karma unit test runner directory injector error
So in my app.module, i have some injectors that are actually directories that store html element directives for templates. The problem is that karma is complaining that the directories are not ...
0
votes
1answer
40 views
Unable to bind my fake array to a scope variable in my test
I'm unable to bind my fake array to a scope variable in my directive test.
My test:
describe('Directive: report - section', function () {
// load the directive's module
...
1
vote
0answers
26 views
karma test runner error: require jquery
I'm new to using karma and unit testing in general. I tried finding a solution by googling this problem, but I wasnt able to find anything useful , as my app/assets/components does not have any jquery ...
1
vote
1answer
17 views
How to change $httpBackend when[method] statements between requests in unit testing?
In my testing i initiate some model data and mock the response:
beforeEach(function(){
var re = new RegExp(/^http\:\/\/.+?\/users-online\/(.+)$/);
$httpBackend.whenGET(re).respond({id:12345, ...
0
votes
1answer
27 views
karma test runner not running any tests
I'm using karma with jasmine and followed online guide by installing using
npm install --save-dev karma
and other necessities
i ran
./node_modules/karma/bin/karma start
and
karma start ...
-1
votes
1answer
16 views
Should I write unit-tests for 'wrapper' methods
I have function in controller of my directive:
$scope.getPossibleWin = function() {
return betslipService.getPossibleWin()
}
betslipService injected into controller
Now I'm thinking how to ...
0
votes
1answer
35 views
How to access controllerAs namespace in unit test with compiled element?
In this fiddle http://jsfiddle.net/FlavorScape/fp1kktt9/ i try to set properties on the controller, not the $scope directly. In the template (in production) we just do myAliasCtrl.somePropertyList and ...
0
votes
0answers
14 views
AngularJS Unit-Testing with $stateProvider for testing the controllers
I have an application which is made up of AngularJS, which loads different pages by just simple clicks...for which I am writing unit-testcases using the framework Jasmine..
Here, I am able to test the ...
0
votes
0answers
35 views
Unit Testing AngularJS directive: scope event listener testing explicit for each test
I am unit testing a directive. It listens for an event, and hides/show on the even listener and also based on one property.
When I emit the event, all the listeners are being triggered. I want the ...
0
votes
0answers
25 views
How to unit testing an AngularJS directive's Cell Highlight feature ?
In this directive I am trying to test cell high lighting when the existing value changes and I haven't made much head way in validating this change. I am using Karma and Jasmine to test code.Here's a ...
0
votes
1answer
17 views
Controlling how each catch in $httpBackend.when() is handled
I'm trying to build some jasmine unit tests around my angular project. I've run into a situation I'm not sure how best to work around.
I use a response interceptor that's capable of retrying a ...
0
votes
1answer
23 views
Karma testing error with sample angular-seed project
For trying Karma testing working with Angular, I get the angular-seed project (https://github.com/angular/angular-seed.git) from github. When running "bower install", it didn't work somehow so I ...
0
votes
0answers
9 views
testing angularjs within a rails app
So far the only resource I've come across with this specific requirement is using a the ruby gem jasmine. I also noticed there are a ton of other resources out there such as protractor, karma and ...
0
votes
1answer
30 views
How to unit test spy on $emit in a directive?
How do I check if $emit has been called in an unit test of a directive?
My directive is fairly simple (for the purpose of illustration):
angular.module('plunker', [])
.directive('uiList', [function ...
0
votes
0answers
16 views
AngularJS unit testing $interval in controller
I am currently using AngularJS 1.2.4 and have trouble in writing unit tests for the code using $interval.
I am using Karma + Jasmine for writing tests.
My controller code:
...
0
votes
1answer
32 views
Angularjs & Karma controller unit test injector:modulerr
In order to apply some unit test to my AngularJS controller, I'm unable to get it working correctly...
This is my Angularjs app declaration :
var ogcApp = angular.module('OGC', [
...
0
votes
1answer
30 views
Testing factory that returns $http promises
Trying to test an angular service that returns an $http GET request and the then handler, but I'm not able to test that the logic actually works inside of the then function. Here is a basic, truncated ...
0
votes
0answers
30 views
AngularJs Jasmine Unit Test Nested Deferred Never Called
I have a controller that after making an initial deferred service request listens for a $rootScope broadcast and then executes another deferred service request. I have set up mocks for all the ...
0
votes
0answers
23 views
Unit testing promises in service in AngularJS
I am new to unit testing and i am unit testing promise in services in angularjs.I am not sure whats wrong with my code,have i done correct.
Any help will be appreciated on how to verify the functions ...
0
votes
1answer
37 views
Unit testing promises in AngularJS with arguments
We're unit testing our services and facing issue spying on methods with arguments of dependent services.
I am writing unit tests for ServiceA
ServiceA.js
angular.module("App").service("ServiceA", ...
1
vote
3answers
124 views
How to provide mock files to change event of <input type='file'> for unit testing
I'm having difficulties with a unit test in which I want to verify the processing of a file, which would usually be selected in the view via <input type='file'>.
In the controller part of my ...
0
votes
0answers
33 views
Testing an angular controller with a service dependency
I am attempting to create a very simple unit test for an angular controller however I am finding a lot of different information with regards to mocking a service giving different approaches with a ...
-1
votes
0answers
19 views
How can I debug Jasmine unit Tests for AngularJS on Chrome?
Do I need additional plugins/dependencies to be injected? I am using jasmine-karma-PhantomJS.
0
votes
0answers
15 views
Loading template with AngularJS jasmine
I am trying to test a directive that is using a template. I am using VS2013 with the Jasmine nuget package, so I run my tests through the browser and not through any runner.
But when I run my test I ...
0
votes
0answers
18 views
Jasmine Unit Test Can't Find Cordova Plugin
So I'm building a hybrid phonegap app with angularjs through the framework Ionic. So for my unit test with jasmine I'm getting a "can't find variable" error from a call to a cordova installed plugin.
...
1
vote
2answers
45 views
Testing AngularJS with Selenium
I have SPA application on on stack ASP MVC + AngularJS and i'd like to test UI.
For a now i'm trying for Selenium with PhantomJS and WebKit drivers.
Testing page - view with single element - the list ...
1
vote
1answer
28 views
Setting up angular unit test on directive that links to external DOM element
This is my test set-up. I'm adding two elements to the $document, and want them to be available to my directive for testing
beforeEach(inject(function ($compile, $rootScope, $document) {
var ...
0
votes
2answers
78 views
TypeError: Cannot read property 'forgotPassword' of null
I am new with AngularJS.. I have built an app..and now I want to test it..
For which right now am writing a very basic testcase for my app's login page using AngularJS, but while running that testcase ...
0
votes
1answer
31 views
How to unit test angular form?
I have been learning AngularJS and things have been going pretty smoothly regarding unit testing, but I've reached a bit of a tricky spot.
Suppose I have a simple form, for example:
<form ...