Questions tagged [angularjs-ngmock]

The ngMock module provides support to inject and mock Angular services into unit tests. In addition, ngMock also extends various core ng services such that they can be inspected and controlled in a synchronous manner within test code.

57 questions
0
votes
0 answers

NgMock acting miscellaneously?

When adding ngMock in dependency injection The login.html page is not loaded var backendMock = angular.module('backendMock',['ngMock']); removing it from dependency and its working fine var backendMock =…
Shubham
  • 189
  • 9
0
votes
1 answer

angular $httpBackend.when mocks - delay response NOT globally

I found this article how to create an artificial server delay when using $httpBackend for mocking data. Is there any way at all to have this on a per-mock basis? Perhaps something like: $httpBackend .whenGET(/\/my\/endpoint$/) …
parliament
  • 21,544
  • 38
  • 148
  • 238
0
votes
1 answer

How do i pass the parameter in Jasmine Unit Test?

How do i pass below list of parameters to the below unit test spec in jasmine? params - "userId" : "user1", "location" : "london", "salary" : "33333", "hobby" : "swimming" This is an approximate unit test spec and not an accurate…
0
votes
1 answer

AngularJs unit test fails because Karma doesn't recognize $scope.$on listeners in the controller

So here's the thing. I've been investigating many threads but couldn't find anything related to my error. I'm trying to test my angular app, (I want to clarify first that I'm kinda newbie to unitTesting) According to this tutorial I've set…
0
votes
2 answers

Angular ng-mock - help matching url routes

I'm trying to use ng-mock to fake a DELETE request but keep getting Error: Unexpected request: DELETE /api/1.0/package/1. How do I properly define the mock url to match the factory request: function deletePackage(file) { return…
neridaj
  • 2,143
  • 9
  • 31
  • 62
0
votes
2 answers

How to use ngMock to inject $controller

I'm trying to learn unit testing for Angular using Karma, Jasmine, and ngMock. There are at least 2 places in the Angular docs that show how to write unit tests for a controller, and I just have a couple of questions about how they're doing…
bobbyz
  • 4,946
  • 3
  • 31
  • 42
0
votes
0 answers

Cant get ngMock to properly inject services into jasmine test

I'm trying to write unit tests for my controllers. I've tried the following setups, none of them have worked: Setup #1: beforeEach module 'PostApp' describe 'HomeCtrl', () -> describe 'test', () -> it 'does stuff', inject ($controller) -> …
dopatraman
  • 13,416
  • 29
  • 90
  • 154
0
votes
1 answer

Conditionally load ngMock into app only if running karma jasmine tests

I am having issues loading my app when including ngMock, so I would like to only load it when I am running my tests as this works fine. Is there a flag or some kind of isTesting() function that gets set when karma runs tests? Something I can then…
Heather Roberts
  • 1,978
  • 1
  • 24
  • 33
0
votes
1 answer

How to check if a GET call is not made in $httpBackend

$httpBackend offers methods for check if an HTTP call is made: $httpBackend.expectGET('/auth.py'); I'm testing a service that has an internal cache and I would like to check if it works correctly. The idea is to check if the GET call is NOT made…
Fedy2
  • 3,147
  • 4
  • 26
  • 44
0
votes
1 answer

How to prevent module's run block from being executed during testing?

I'm trying to unit test a service provided by an angular module I've created, however I'm struggling to find a way to do so without also invoking the module's run block when it is loaded in. Does anyone have any ideas?
Keir
  • 440
  • 6
  • 15
0
votes
1 answer

Injector error with angular

I have the following error on my APP Error: [$injector:unpr] http://errors.angularjs.org/1.3.2/$injector/unpr?p0=ProductResourceProvider%20%3C-%20ProductResource My Scenario is as follows, a simple app that gets info from a webservice, but with ng…
Luis Valencia
  • 32,619
  • 93
  • 286
  • 506
-1
votes
1 answer

Angular test failing to instantiate module with Jasmine and Karma

I have setted up a test environment with Angular 1.6.6, ng-mock 1.6.6, Jasmine and Karma. But even with the easiest test I'm getting a [$injector:modulerr] when trying to inject the deloreanApp module Failed to instantiate module deloreanApp due…
Rafa Romero
  • 2,667
  • 5
  • 25
  • 51
1 2 3
4