Tagged Questions
1
vote
1answer
18 views
Unit tests breaking using AngularJS, Pusher + Karma
A project I am working is using Pusher, along with Karma for Unit tests. The unit tests are currently failing , citing the following error:
ReferenceError: Can't find variable: Pusher
at runBlock ...
0
votes
0answers
6 views
Creating a mock filter for angular-translate using translate as an element attribute, not filter
I am running some karma/jasmine tests and have all tests passing when I use translate as a filter, i.e.:
<ANY>{{'component.buttonName' | translate}}</ANY>
But if I change the translate ...
0
votes
0answers
25 views
Function from dependency and Jasmine test
I have a problem with AngularJS Service and Jasmine test. I use service dependency in another service, and when I try to make Unit Test I get an error:
TypeError: undefined is not an object (...
0
votes
1answer
32 views
How to test observable in angular 2
Have my test suite setup, but can't figure out how to test an observable that relies on a 3rd party module to get filenames off a server.
How do I mock an observable so that I can test my ...
0
votes
1answer
9 views
Running Jasmine standalone for testing Angular app
So I am currently trying to test my Angular app using Jasmine standalone.
However I can't seem to get even my angular module loaded. It throws the following error:
Failed to instantiate module ...
0
votes
2answers
14 views
How to mock objects inside $scope or $window in AngularJs tests using Karma and Jasmine?
I am new to testing AngularJs controllers with Karma and Jasmine.
I'm trying to test this controller:
angular.module('app.dashboard.admin', [])
.controller('AdminCtrl', function (locale, $log, $...
0
votes
1answer
42 views
How to test Angular 1.6 component with injected service?
I want to test my Angular component which is syntactically based on John Papa's styleguide:
'use strict';
angular.module('MyModule')
.component('MyCmpnt', MyCmpnt())
.controller('MyCtrl', ...
0
votes
1answer
43 views
Angular Test does not call a promise callback
Environment:
Angular 1.5.8
Unit Tests with Karma/Jasmine
This is my controller, which aims to get a value from $stateParams and uses that, to perform a DELETE request, later on.
Right now it should ...
0
votes
0answers
20 views
How to unit test “with using” translate filter in Angular
Here is my filter X, which uses the standard translate filter.
.filter('X', function ($filter) {
return function(value) {
...
... $filter('translate')(...);
...
...
0
votes
0answers
11 views
Multiple loaded modules with karma and webpack
got a problem with creating unit test environment using karma with webpack. The problem is, that webpack while creating a bundle, creates multiple instances of one module (I guess). I'm trying to test ...
1
vote
1answer
19 views
How to mock $cookiestore.put in AngularJS/Jasmine
I want to test my Authentication.Login service function.
In this service is call of another service and a cookiestore.put method.
I want to mock both function. But Im still get a error :/
I have ...
0
votes
1answer
26 views
Unit test on Angularjs with Jasmine and Webpack, error Unknown provider
I would like to ask how to solve this error which won't let me write any test.
This is the Angularjs factory (service.es6) I would like to test:
import Rx from 'rxjs/Rx'
var TheMiddleModule = angular....
1
vote
0answers
30 views
What should we unit test for Angular2 Component
I am newbie to Angular2. I wrote a small application in Angular2 which has few components. I want to write unit tests for my client application.
Someone suggested me when we write unit test for a ...
0
votes
0answers
12 views
Mock httpBackend request globally
In AngularJs unittest (Jasmine/Karma), we need to put httpBackend.whenGET('/.*/').respond('')
and some other default responds in the global beforeEach().
However, we get Error: Injector already ...
0
votes
2answers
19 views
How to mock angularJS service with $resource that has custom action?
https://docs.angularjs.org/api/ngResource/service/$resource
From the API of $resource we know that there is a custom action in $resource method that can be called. My question is, how to mock a ...
1
vote
0answers
21 views
Error : Possibly unhandled rejection still exist after update to AngularJS 1.6.1
I have upgrade angular to 1.6.1 and angular-ui-router to 0.4.2.
I still get this error :/
The solution in the app config : $qProvider.errorOnUnhandledRejections(false); is not clean :/
Anyone knows ...
0
votes
0answers
15 views
unit test $watch callback function:Karma
I have a scenario where i need to test the callback of $watch
I am using karma and jasmine as a framework.
controller:
$scope.$watchCollection(function() {
return productsFilterService....
0
votes
0answers
20 views
Test modifier keys in karma unit test
I am trying to test something if both shift key and down key are pressed TOGETHER.
My Code:
if (evt.keycode == '40') {
if (evt.shiftKey) {
$scope.data.checked = true;
}
}
So I wrote ...
0
votes
0answers
31 views
unit testing angular service, beforeEach inject doesn't execute
I'm trying to write unit tests for an angular service with jasmine/karma. I have a similar service test, which works just fine. But this one has some additional dependencies, is in a different module ...
1
vote
0answers
46 views
Ng-mock: $compileProvider doesn't have method 'preAssignBindingsEnabled`
I've been rewriting directives in Angular 1.5.8 to components. I want to write unit tests with '$componentController` just like described here: https://docs.angularjs.org/guide/component.
The ...
1
vote
1answer
20 views
Asp.Net MVC Angularjs Unit testing without nodejs
The application I am currently working have a Asp.Net MVC serving up the pages and angularjs on the client side. I am looking to set up the unit testing on the angularjs controllers, services. Is ...
0
votes
1answer
27 views
AngularJS test $q.all service jasmine with multi urls
I want write to some unit test for my app and I'm stuck when want write test for my service.
My service code below:
function CurrenciesService($http, $q)
{
return {
...
0
votes
0answers
35 views
Karma, Jasmine, Uncaught Error: <toHaveBeenCalledTimes> : Expected a spy, but got Function without test
Sorry in advance for my bad english..
I am testing my application with Karma and Jasmine and I have a really strange error.
I have 9 tests and when I run tests it seems that karma finds a 10th test. ...
0
votes
0answers
14 views
Unit test for callback function in angularJs using jasmine
How to unit test a callback function using jasmine.
let somefunctionCallback = function (error, response) {
if (!error) {
$('.loading').hide();
$scope.infomsg = response.data.message;
$...
9
votes
2answers
231 views
Angular JS Testing with Karma Jasmine
I have a sample route like this :
angular
.module('appRouter',['ui.router'])
.config(function($stateProvider,$urlRouterProvider){
$stateProvider
.....
...
1
vote
1answer
36 views
Npm test throws errors but app runs without errors
I have been working on an Angular 2/TypeScript application. Originally I had my application and unit tests running fine. But now I am getting errors when I run my unit tests.
Can't bind to '...
1
vote
0answers
18 views
Angular Unit Test : No pending request to flush
I am new to Karma so this might sound trivial. I have the following route structure in place.
angular
.module('appRouter',['ui.router'])
.config(function($stateProvider,$...
0
votes
1answer
26 views
Angular UI Router Testing With Resolve
I am quite new to karma and I need desperate help on the same.
I have my routes defined as :
angular
.module('appRouter',['ui.router'])
.config(function($stateProvider,$...
-1
votes
1answer
19 views
AngularJS with Karma - how would I write a unit test for the controller
Same code as: AngualrJS with Karma - how do I write a unit test for a factory?
I'm not sure how to write a unit test for the controller.
How do you write one for the controller with the factory and ...
1
vote
2answers
30 views
AngualrJS with Karma - how do I write a unit test for a factory?
I am writing a simple AngularJS 1.x web app.
I have a module:
main.js:
var app = angular.module('app', []);
factory.js
app.factory('DataFactory', function(){
var DataService = {};
...
0
votes
1answer
13 views
Mock an AngularJS module to pass to another
I'm having some trouble mocking a factory belonging to one of my modules. The factory I would like to mock has 2 dependencies:
Factory class:
angular.module('serviceapp')
.factory('claims.service', [...
0
votes
1answer
19 views
unit testing directive with link using controller
I'm trying to unit test my directive that set form validity depending on a controller variable.
My directive code :
angular.module('myModule',[])
.directive('myDirective', function() {
...
0
votes
1answer
32 views
How to Jasmine test value of Object.constructor and reduce repition in it statements - AngularJS
I defined an object model in my AngularJS application... it looks like so:
.factory('Watermark', function () {
// Constructor, with class name
// Assumption: that backend gives us a topic or ...
0
votes
1answer
23 views
Map Object in .run block breaks my unit test: ReferenceError: Can't find variable in app/scripts/app.js
I set up a mock backend in my AngularJS app using ngMockE2E as I am waiting for an API. In my .run block I declare my various $httpBackend.whenGET and $httpBackend.whenPost methods and I have a ...
1
vote
1answer
32 views
Angular Directive Isolate Scope Unit Test Failed
I am trying to unit test an Angular Component with Karma Jasmine for the very first time.
My index.html looks like :
<body ng-app="heroApp">
<!-- components match only elements -->
<...
1
vote
0answers
44 views
Angular 1.5 Component Unit Testing with Karma Jasmine Failed
I am trying to unit test an Angular Component with Karma Jasmine for the very first time.
My index.html looks like :
<body ng-app="heroApp">
<!-- components match only elements -->
<...
0
votes
1answer
78 views
Unit testing Angular 2 Service
Im new to whole unit testing scene with Angular, so would be great if guys could point me in the direction.. Im trying to create a fake service and pass back data to which i can run a few simple test.....
0
votes
1answer
32 views
Angular Karma/Jasmine testing: How to mock a service in controller with promises?
I am trying to unit test my controller. The function that I am trying to unit test is:
function myFunction() {
MyService
.myMethod(thing1, thing2)
.then(function ...
0
votes
0answers
41 views
Mock AngularJS $http response in unit test
I'm trying to write unit tests for an AngularJS application with Jasmine.
I'd like to test a function which contains a $http call like the following:
Main controller
var url_ajax_data = "my/custom/...
0
votes
0answers
33 views
Jasmine unit test wait for asynchronous calls
How do I make Jasmine wait for asynchronous functions to finish before running expect's?
I want to test scope.init() in my controller. This function contains 3 asynchronous calls similar to this one
...
1
vote
0answers
39 views
Unexpected request: No more request expected, Jasmine Angular unit test
I am working on a code that has some unit test failing which I am trying to run. The unit test is
it('opens a confirmation dialog when deleting a layer and calls the delete wizard', function ...
0
votes
0answers
10 views
How do you update a mocked service return value in each test iteration of an angular service unit test
I am trying to write a unit test for an angular service where I have to mock an injected service and provider. I want to change the return values for each test.
Something like so:
service:
(function(...
1
vote
0answers
12 views
Writing unit tests with Jasmine for AngularJS controller with Google maps, modals
I have been coding for so many years, but for for the first time I'm about to write test cases for an angularJS app with Jasmine... I went through many Jasmine tutorials, but most of them include ...
1
vote
1answer
59 views
How do we write Unit test cases (Jasmine) for nested functions?
am writing a test case for the following scenario.The code coverage is not fully covered. I don't know whether it's possible to write or not. if I ask anything wrong means kindly guide me to write a ...
1
vote
1answer
89 views
How to unit test an Angular 1.5 Component template?
So, here's my test:
describe('My Test', function(){
var $componentController, $compile, controller, scope;
beforeEach(inject(function($injector, $rootScope, $templateCache){
$templateCache....
0
votes
1answer
19 views
Testing if callback have been called using $rootScope.$broadcast and $scope.$on
I've been trying testing if a callback have been called on my controller.
Controller
(function () {
'use strict';
angular
.module('GeoDashboard')
.controller('CiudadCtrl', ...
0
votes
0answers
12 views
$provide.factory don't overwrite real factory
I have angularjs app and I'm creating unit tests for directive that look like this:
angular.module('divosUiApp.widget', [])
.directive('filterDate', filterDate);
filterDate.$inject = ['$...
0
votes
1answer
27 views
How to check if a function is available in instantiated controller for unit testing in Jasmine
I am trying to unittest a controller in AngularJS for the first time. I want to test if the login-function in this controller calls the right service but I get the error, that the function doesn't ...
1
vote
0answers
11 views
How to test an Angular 1.x component that uses Angular Material md-tabs - issue with output/event/callback
The issue here is that the second it test fails in this unit test even though in the real browser that output callback is called just fine.
How can I write a unit test so that I can test that md-tabs ...
2
votes
1answer
42 views
Write angular2 tests and changing the mock return values - make it DRY?
I'm writing some tests for a service and I'm altering the response from mock functions to test various cases. At the moment, every time I want to change the response of a mock, I need to reset the ...