Tagged Questions
0
votes
0answers
6 views
angularjs: Unit testing with simulate click
I'm unit testing a directive, and I have something like this
<bar-foo>
<a ng-click=show = !show">click me</a>
</bar-foo>
var scope = el.isolateScope();
...
1
vote
0answers
6 views
How to unit test the 'resolve' property on an Angular-UI Bootstrap Modal component
I'm trying to write a unit test that asserts the correct variable is being sent to the resolve property of ui.bootstrap.modal from the Angular-UI Bootstrap components. Here is what I have so far:
// ...
1
vote
0answers
11 views
AngularJS e2e tests protractor setup
I spent all day trying to setup test setup for angularJS. I had generated angular app with yo angular and then I modified grunt conf file like so:
// Test settings
karma: {
e2e: {
configFile: ...
0
votes
0answers
16 views
How to test angularJs http request jsonp
So, i am trying to follow this tutorial while trying to create some unit tests along the way.
Well i am stuck at trying to test the $http request to the ergast developer api. As u can see in the ...
0
votes
1answer
20 views
How to generate test fixtures to mock a REST API in an AngularJS project?
I'm interested in learning more about how to write good unit tests for an AngularJS project.
We are using Karma, but currently we do not have an instructure for generating fixtures to mock our REST ...
0
votes
0answers
16 views
How to test angular-js controller without jasmine?
I'm trying to setup tests with cucumber-js, but don't want them to run end-to-end. Instead, I'd prefer to have the same options as in Jasmine test, eg. inject a controller from module, have a mocked ...
1
vote
0answers
23 views
AngularJS: Unit test views - best practice
Can anyone share her/his experience with unit testing views? I read a lot of tutorials about how to do unit testing with views, but everything has some drawbacks.
I came along with the following ...
0
votes
1answer
34 views
Angularjs + karma many controllers in module MainCtrl
I have a module called MainCtrl in file MainCtrl.js
angular.module("MainCtrl",['ui.bootstrap']);
I'm trying to accomplish a Jasmine test (using Karma) to validate controller. Ideally, my app would ...
0
votes
3answers
43 views
Testing if a method returns an HttpPromise
In angularjs, while testing a service, I want to check if the returned object is an HttpPromise.
Right now I am doing the following -
obj.testMethod()
.should.be.instanceOf($q.defer());
1
vote
1answer
48 views
Angularjs is not able to find my controller
I am using angular-mock to inject my controller for unit testing. I am failing to do so since I keep getting the following error.
[$injector:unpr] Unknown provider: PatientRecordsControllerProvider ...
0
votes
1answer
32 views
Unit Testing a AngularJS service?
Hey, I need help with my testing service.
I have this service: MyService.js
And this controller:
angular.module('MyControllers', [])
.controller('MyCtrl2', ['$scope', 'FnEncode', function ...
1
vote
1answer
34 views
Mocking Controller Instantiation In Angular Directive Unit Test
I am unit testing an Angular directive and would like to mock or stub in some way the instantiation of the named controller in the unit test.
So first I suppose on to some code...
'use strict';
...
0
votes
1answer
26 views
AngularJS Directive testing a elm.on() binding
Im getting errors on my unit tests with the following directive:
.directive('flashMessage', function() {
return {
restrict: "E",
replace: true,
template: "<div ...
0
votes
0answers
19 views
Unittesting angular directives with external templates
I am trying to unittest our angular directives which are implemented with external templates.
As far as I can find there are only two options:
use $httpBackend to respond with the template when ...
1
vote
1answer
25 views
Unit testing promises in controllers in AngularJS
We recently started incorporating promises in our controllers to handle multiple requests at the same time and it works in the app, but unit testing these has been proven to be more than difficult and ...
0
votes
2answers
35 views
AngularJS Unit testing a link in a directive
I am trying to write unit tests to test my directives. However, when I invoke a click on a checkbox, it will not update the model.
How can I make it change the model? Somehow it doesn't seem to bind.
...
0
votes
1answer
66 views
Unit testing Angular with Breeze
I am trying to unit test angularjs with QUnit but get the error messages: $httpBackend.whenGET is not a function, $httpBackend.when is not a function. I have included angular mocks and angular breeze ...
0
votes
0answers
28 views
Unit test with Jasmine - does not inject a module
I created angular modules using requireJS, and I am trying to test them with Jasmine but it's not working.
I have a main controller module, which requires another controller module like this.
...
0
votes
1answer
29 views
Requirejs and Karma: cannot detect the source file
I am trying to test my angular scripts using Karma and requirejs, but I keep getting this error
Firefox 28.0.0 (Mac OS X 10.9) ERROR: 'There is no timestamp for ...
0
votes
0answers
16 views
Angularjs - Testing using data from actual database
I'm working on a single page application using angularjs backed by asp.net web api. For this project I want to do acceptance testing based on scenarios from user stories. I want to test the whole ...
0
votes
1answer
32 views
When should I use $provide versus Jasmine Spies in my Angular JS Unit tests
I work on a large Angular App and initially we done a lot of our tests by using $provide to mock services. However we now have a lot of Jasmine Spies in our tests in order to stub and spy on services.
...
1
vote
1answer
31 views
Testing jquery click call back
Am a newbie in jasmine, trying to test the jquery click call back function
$('#upload-btn').click(function(){
$("#myModal").modal('show');
});
My test code is
describe('upload button attaches ...
1
vote
2answers
58 views
Angular Jasmine - mock service (angularjs-rails-resource) - TypeError: object is not a function
This is Rails 4.0 App with angular-rails gem and jasmine gem. I also use angularjs-rails-resource.
I have simple controller:
app.controller('new', function ($scope, Appointment, flash) {
...
0
votes
0answers
14 views
How to setup jasmine with your angularjs app
I need to write some unit test cases for my angularjs app.
I stuck with how to include jasmine in an already existing app and then how to use that to write test cases.
I did npm install jasmine-core ...
0
votes
0answers
26 views
Angularjs - load json file in karma+jasmine
I'm trying to accomplish a Jasmine test (using Karma) to validate JSON config file. Ideally, my app would simply load a JSON file into app.js, then let me parse through to check for server name.
my ...
0
votes
0answers
40 views
Best unit test framework for Angularjs app
I need to start unit testing for my angularjs app, I am a bit confused with, which is best framework out of Protractor or Jasmine.
Majorly I need to test controller functions, services, dependency ...
0
votes
0answers
19 views
properly get access to an angular js service in a unit test
I have the following mock service:
angular.module('tftest.services')
.service('mockSwfObjectService' , function() {
var mockObject = {
mockFunction : function() {return true}
...
0
votes
1answer
17 views
How do I test for default route with angularjs + ui.router?
In the gist https://gist.github.com/CarmineM74/10021667
You can see 2 files:
app.coffee
contains states configuration
states.coffee
The goal for this test is to check for correct fallback behaviour ...
1
vote
2answers
39 views
Unit-testing, waiting on a promise when $http does NOT get invoked
I have a unittest where a service returns a promise. Sometimes that service might make a $http request, sometimes it won't (It implements a cache of sorts). In either case, it resolves the promise, ...
0
votes
2answers
20 views
Modifying $scope Values for Angular Controller Unit Testing
All,
I have a unit test suite for a AngularJS controller that follows the pattern beforeEach():
var ResourcesCtrl,
scope, rootScope, loc, ctrl;
// Initialize the controller and a mock scope
...
0
votes
1answer
15 views
AngularJS: how to “create” controller in unit test, and why scope is not defined?
everywhere in application my company created we used this example of how to create a controller :
app.myFunnyController = function($scope.....){}
but i see that everywhere in test people are using ...
0
votes
2answers
58 views
Globally mock object in angularjs for jasmine/karma testing
I have an object that I am mocking up for unit testing. Essentially in my test file I mock it up as follows:
var mockObject = {
mockMethod1 : function() {return true},
mockMethod2 : ...
1
vote
1answer
52 views
Karma 'Unexpected Request' when testing angular directive, even with ng-html2js
After spending the last day trying to make this work, I've found that I've circled back around to the same error I was having at the beginning:
Error: Unexpected request: GET test-directive.html
I'm ...
0
votes
1answer
56 views
TypeError: $scope is undefined in Angular controller unit test with Jasmine
This is a very simple, quite pared down test and controller. My controller 'LedgerCtl' has an injected service 'LedgerService' that I test elsewhere, so in my LedgerControllerSpec I created a ...
1
vote
0answers
35 views
Error When Unit Testing AngularJS Directive that uses ngInclude w/ QUnit
I am currently trying to set up Unit Testing for my Angular directive using QUnit. Everything was going great until I tried to use the ngInclude directive. I am now receiving the following error when ...
1
vote
1answer
27 views
Unit Testing Directives in Angular Js
Im new to angular js testing. We are using Karma/Jasmine to test. I am trying to unit test a directive. Essentially I want to make sure that once it is all compiled that element now contains 'id="tf-' ...
0
votes
2answers
34 views
Weird error when testing angular controller with $httpBackend
I've been trying to fix it for hours. Unfortunately with negative effect so please help me.
In my application I want to test my $http requests. I'm doing it by using $httpBackend.
Here is my ...
0
votes
2answers
101 views
Unit testing in AngularJS - Mocking Services and Promises
In Angular everything seems to have a steep learning curve and unit testing an Angular app definitely doesn't escape this paradigm.
When I started with TDD and Angular I felt that I was spending ...
-1
votes
0answers
33 views
Karma Unit testing Directives in AngularJS
In angular I have a directive that is mocked essentially like this:
angular.module('app.directives').
directive('myDirective', [Obj]);
function Obj() {
var ident = getRandomNumber();
link: ...
0
votes
1answer
32 views
How to unit test an AngularJS Controller with $setPristine
I have the following controller:-
appControllers.controller("TaskAddController", function ($scope, $timeout, taskService) {
$scope.task = {};
$scope.messages = {
error: false
};
...
2
votes
1answer
96 views
Idiomatic composition of $http and $httpBackend in AngularJS 1.2.2
I have an AngularJS/Jasmine unit test that works fine with AngularJS 1.0.7, but doesn't work in Angular 1.2.2:
servicesSpec.js
describe('services', function() {
beforeEach(module('workPadApp'));
...
0
votes
1answer
11 views
Trigger a function in a controller with Karma
In an angular controller I have a function on my scope that looks like this:
$scope.myFunction = function(val) {
$scope.myVar = val;
$scope.mySettings.myPath = $scope.myBase + $scope.myVar;
}
In my ...
0
votes
1answer
33 views
Angular Unit testing with Karma
I have an angular app that i am developing tests for. In the app.js file i have something like this:
angular.module('app',
[
'app.config',
'app.factories',
'app.directives',
'app.controllers'
]
);
...
1
vote
4answers
80 views
Is this really the right way to do angular form validation?
I'm trying to learn angularjs, and at the moment am looking at forms and form validation. By following the docs on the angular site, I have a template html file as follows:
<form role="form" ...
2
votes
0answers
27 views
Mocking HTTP calls when using the ArcGIS JavaScript API
I'm an AngularJS developer, so most of my unit tests that rely on HTTP use the $http service and the mock $httpBackend service.
I'm integrating some code with the ArcGIS JavaScript API, which makes ...
-1
votes
1answer
27 views
How do you mock $rootScope in an angularjs service?
Given i have a service like this.
angular.module('app')
.factory('Session', function Session($rootScope, $cookieStore) {
var user;
if (user = $cookieStore.get('user')) {
...
1
vote
1answer
25 views
How can mocha know when event fired on a Controller $scope using $broadcast inside of a $promise?
I could not find any other question/answer that met my needs, so here it is:
In an AngularJS (1.2.14) controller, I have an event listener that executes an ajax call to fetch some data when an event ...
0
votes
1answer
39 views
Reset service object after each test
I'm trying to test my Auth service in my AngularJS app.
This is the service:
'use strict';
angular.module('testApp')
.factory('Auth', function ($window, $http, $location, $q) {
var ...
0
votes
0answers
37 views
AngularJS unit-test 'ReferenceError: humane is not defined'
I am attempting to incorporate the humane.js notification library into my AngularJS app. I have wrapped the humane.js use into an Angular service, and the app is working correctly. But when I attempt ...
0
votes
0answers
36 views
Angularjs injected controller empty when testing with Jasmine
I am currently working with Angular and using Karma and Jasmine to make the testing. The filters, for example are injected to the main module and can be tested without any problem, but when I try to ...