Tagged Questions
0
votes
1answer
16 views
Testing an angular service
This might be a really silly question but I couldn't find an answer anywhere else.
I want to unit test a service that for now has two simple operations:
...
0
votes
1answer
19 views
angularjs test verify that event is caught
I've recently started learning how to test in angular with karma/jasmine.
Here is the scenario:
I have a directive that listens to an event, and when called it calls a function on the directive ...
0
votes
0answers
14 views
Unit testing $rootScope.$on() handler in Angular.JS
Given I have a service that subscribed to a certain event handler, say:
angular.module('myModule')
.factory('myService', ['$rootScope', function($rootScope)) {
return {
myMethod: function ...
0
votes
1answer
34 views
Cannot read property 'spyOn' of null - Mocking a promise in angularJS unit test
I am trying to mock a function which returns a promise using spyOn with the following code:
beforeEach(inject(function($controller, $rootScope, $q) {
scope = $rootScope.$new();
q = $q;
...
1
vote
1answer
13 views
Karma error: myApp is not defined
I'm trying to test the Angular seed project with a clean install of Karma in a different directory. I haven't modified the Angular seed project. Why are myApp and myApp.View1Ctrl not defined?
My ...
0
votes
1answer
17 views
Jasmine + AngularJS: Global services causes Unexpected GET request
I have a service, $language, that gets called in app config (so before every Spec runs). The method called, $language.update(), triggers $translate.use() (which in turn triggers an $http.get()). This ...
0
votes
1answer
10 views
How to test angular $cacheFactory?
I am using $resource in an angular service.
I want to use my own custom cache based upon $cacheFactory, rather than the built-in $http cache, so that I can manipulate the cache when responses arrive ...
0
votes
1answer
26 views
Angular Unit test fails with Error: Unexpected request: GET
I am new to angularjs testing and have been trying to run this test but it fails with same error again and again. I have viewed questions here and read the docs but haven't got to the cause of this ...
0
votes
0answers
7 views
How to mock ngDialogData?
Following is my code snippets in which i got the error something like this "$scope.$parent.ngDialogData is undefined" in
which i already declared.
For example,
In my Controller i have written
...
1
vote
1answer
26 views
Guidance on unit testing REST call in controller returning a promise
I'm able test - $scope.dvModel = DienstverlenerDetailService.query(); - accordingly. I cant figure out how to test the commented-out lines. Sure could you use some guidance on that.
...
0
votes
0answers
21 views
Unit test a Factory with dependancies
How would one unit test this? This factory is injected in a Controller but there I'm using spyOn to mock the query call on $resource in the factory. Should I be testing this factory stand alone ? Or ...
0
votes
0answers
17 views
Unit-testing angular.value( )
I am using angular.value to handle/store some data and I would like to unit test this so its covered in coverage.
angular.module('dvb.transferObjects', []).value('FilterTransferObject', ...
0
votes
1answer
25 views
Not able to inject logger
app.admin.routes.js
(function () {
'use strict';
angular
.module('app.admin')
.run(appRun);
appRun.$inject = ['routeHelper', ...
0
votes
1answer
43 views
Angular Jasmine (1.3) Controller Mock Service testing
There is probably too many of this sort of question on here, but none that I have found come up with one good solution.
The problem, in my view, should be too common.
dirty pseudocode:
Acontroller
...
1
vote
1answer
34 views
Why does the $rootScope state persist between my tests?
Disclaimer: I'm very new to unit testing Angular apps. Obviously (as you'll see from my problem) I lack a deeper understanding of the angular mechanisms, including the injector service and the ...
0
votes
1answer
24 views
Mocking an asynchronous web service in Angular unit tests
I'm building an Angular app, and I'm writing unit tests for it. Yay unit tests. I want to mock a particular web service that I'm using (Filepicker.io), which has both a REST API as well as a ...
1
vote
0answers
22 views
AngularJS + Karma: Unit Testing without loading html as modules
These days I've questioned myself why we need to load the HTML files as modules in the beforeEach section while testing in AngularJS + Karma. I'm using grunt to run karma and I created a task to run ...
0
votes
1answer
38 views
Unit testing controllers (Jasmine/Angular) that run code when the page loads
I'm attempting to unit test some angular js controllers that I have written within the jasmine testing framework. I've got everything set up so that I am able to create instances of my controller, and ...
1
vote
2answers
44 views
jasmine can not mock the elasticsearch object
I'm implementing an application using yoeman, grunt, angular, grunt-jasmine, karma, elasticsearch. I need to write a test for my custom service (names elasticSearchService) which call elasticsearch ...
0
votes
0answers
26 views
Cant seem to get 'karma-ng-html2js-preprocessor'doing its work
Keeps on giving me this error: Module 'templates' is not available! You either misspelled the module name or forgot to load it.
I implementend unit testing of Directives in several Angular projects ...
0
votes
1answer
30 views
How to test a service in Angular with $q
I have a simple service:
.factory('list', function($q, $timeout) {
return {
get: function() {
var dfd = $q.defer();
$timeout(function () {
...
0
votes
1answer
27 views
Loading test image into canvas
I'm trying to test an AngularJS service that gets handed the ImageData from a canvas, does some pattern recognition, and returns the recognized patterns. I would like to write a unit test (not an E2E ...
0
votes
0answers
19 views
Unit testing UI behavior in Angular Controller?
I have following code in an angular controller that sets a css class 'active' on the clicked element and then removes it after 2 seconds. Please see the code below
$scope.tempSelected = (event) ...
2
votes
1answer
38 views
Angular/Jasmine testing with deffered promises
I am testing a controller using a combination of angular and jasmine, and am not completely sure about using deffered promises.
This is my spec code.
describe('Controller Tests', function(){
var ...
0
votes
1answer
23 views
How to correctly accessing the scope and controller of a directive in a Jasmine unit test
The gist of my issue is that I don't think I am correctly accessing the scope and controller of my directive in accompanying unit tests.
I have a directive that looks something like this:
...
1
vote
1answer
35 views
Jasmine.js: How to spyOn a dropdown list
I have a fromDate text field in my script as:
var fromDate = document.getElementById('fromDate').value;
I know how to spyOn this textbox in jasmine.js:
var params = {
'fromDate': { ...
4
votes
1answer
72 views
Should we use CSS in Karma Unit level tests in AngularJS projects
Say your Javascript performs some element/position calculations e.g. in angularjs directive.
In order to test this Javascript code is it appropriate to include CSS in karma.conf.js ?
I see that ...
0
votes
1answer
23 views
Trying to test Angular with Karma/Jasmine, but can't get the Jasmine tests to set $scope correctly
My Angular script looks like this:
var app = angular.module("myApp", []);
app.controller('TestController', function ($scope) {
$scope.test= "TEST";
});
My test file looks like this:
...
3
votes
1answer
41 views
Cannot test directive scope with mocha
I have a simple directive with an isolated scope that I'm trying to test. The problem is that I cannot test the scope variables defined in the link function. A watered down sample of my directive and ...
2
votes
1answer
53 views
Unit testing Angular Controller that uses Kendo Grid/Datasource
My project is using AngularJS + Kendo-UI. I'm trying to test one of my Controllers that uses a Kendo-UI Grid:
angular.module('myApp')('DevicesCtrl', function ($scope) {
$scope.gridOptions = {
...
1
vote
1answer
88 views
$browser.$$checkUrlChange is undefined in a jasmine test
I have the following test:
it('should maintain a bind between the data at the $scope to the data at the ingredientsService', function(){
$scope.addFilters('val1', $scope.customFiltersData, ...
0
votes
1answer
25 views
Angular Karma unit test with multiple digest cycles
I have a watch on my CRUD object person and I have watches on my select objects. In my unit test I want the initalization of the person object to initialize the select objects and I want changes in ...
0
votes
0answers
35 views
Unit test an Angular-Kendo Grid Datasource - all code paths
I'm writing custom Angular directives for a new application and unit testing them using Jasmine. However, I can't for the life of me figure out how to get full code coverage (or even 80%) on the Kendo ...
0
votes
1answer
74 views
Testing Angular with Gulp-mocha: “Window is not Defined”
I am setting up a project with Gulp to run unit tests with Mocha, including Angular tests. I have the basic set up working (indexOf, etc.), however when I include angular-mocks I get this error or a ...
2
votes
0answers
31 views
Unit testing Angular JS controllers
My Jasmine unit test is as follows
describe('controllers', function () {
'use strict';
beforeEach(module('myapp.controllers'));
angular.mock.module('myapp.controllers', function ...
1
vote
1answer
21 views
jasmine test is not working for angulardirective?
trying to test my directive with jasmine but is not failing where it should because of the wrong date(.demo):
describe("Unit: Testing Directives - ", function() {
var $compile, $rootScope;
...
0
votes
1answer
27 views
Angular Jasmine Service Testing broadcast not called
I have a fairly simple service that basically catches error, enhances them with a specific error type and error message and broadcast the error event so that parts of my application can deal with the ...
0
votes
0answers
32 views
How to setup testing Angular App with Chutzpah in Visual Studio
I have an AngularJS app inside of Visual Studio with Chutzpah installed to try and add tests to this app. I have the web app in 1 application and then I have a separate app that contains the tests. ...
0
votes
0answers
49 views
Angular dynamically replace directive with another directive whose name is provided
I have a placeholder directive whose job is to replace itself with another directive provided by an attribute on the placeholder directive.
.directive('cardPlaceholder', function ($compile) {
return ...
0
votes
0answers
27 views
Mocking Angular module dependencies in Jasmine unit tests using requirejs
I am trying to configure my karma jasmine unit testing with requirejs.
I have created custom mocks across the unit tests specs but i see them repeating across several other unit tests.I am planning ...
6
votes
2answers
203 views
Total test execution time using karma runner
We've currently switched to running unit tests remotely on browserstack in multiple browsers on multiple operating systems with the help of karma-browserstack-launcher plugin.
Currently the output of ...
0
votes
1answer
16 views
How to see which unit test failed
I am new to Karma/Jasmine unit test platform and I am working on an existing Angular project which uses Karma/Jasmine for unit tests. This is a large project and there are approx 2000 unit tests which ...
0
votes
1answer
43 views
Jasmine Test: How to mock a method inside a controller in AngularJS
I am using angularjs and my controller looks like this:
(function (app) {
var myController = function ($scope, myService) {
var onData = function (response) {
if (!response.data || ...
0
votes
0answers
24 views
Testing http request in controller angularJS
How to test Get request which is in controller ? Something like refresh function or when you want to call function afer u click submit.
Normally I used $httpBackend.flush(); to check this ...
2
votes
2answers
56 views
bindToController in unit tests
I'm using bindToController in a directive to have the isolated scope directly attached to the controller, like this:
app.directive('xx', function () {
return {
bindToController: true,
...
1
vote
1answer
20 views
Unknown provider: $xProvider <- $xService
I'm having an issue with Karma and Jasmine while using AngularJS. What I'm trying to do is test a controller that will make some posts available to the view from a service. Here's my controller:
...
0
votes
3answers
62 views
Can you even test Breezejs?
I've been trying to test an angular app with Jasmine and they work pretty well. I'm also developing an Angular app based in John Papa's Hottowel.
But alas, the testing is impossible because BreezeJs ...
0
votes
1answer
42 views
Breezejs unit test with jasmine karma angular
I'm building an app based in Breeze and Angular
They work pretty well together but the unit test is a problem.
This is a pretty vanilla test but Breeze keeps getting in the middle:
...
0
votes
1answer
9 views
how to setup jasmine-html in yeoman angular project
I have a AngularJs project using yeoman, karma and jasmine as a test framework, every specs are running file in the console mode, but how can I view in the HTML mode. I saw the browser window appears ...
0
votes
1answer
43 views
modulerr in filter test jasmine/angular injection
I am trying to run an Angular test on my filter 'manufacturerFilter'.
describe('productApp', function() {
var manufacturerFilter;
beforeEach(function() {
module('productApp', ...