Questions tagged [spyon]

116 questions
0
votes
1 answer

Jasmine Js - SpyOn Fakecall during the controller initialization

I have seen a set of duplicates for this question but was unable to solve the issue. I have a controller and during the controller initialization, fetchtemplate() is getting called first and then my mock fetchtemplate() is getting called. How do I…
M3ghana
  • 1,231
  • 1
  • 9
  • 19
0
votes
1 answer

Angular Jasmine spyOn $resource Unexpected request

I am unit testing an Angular controller which calls a service to get json data. I'm using Jasmine spyOn to spy on my service's query method like this: spyOn facilitiesService, 'query' .and .callFake (success, error) -> …
Matt
  • 823
  • 1
  • 8
  • 17
0
votes
1 answer

Angular Jasmine SpyOn $resource Handle Errors

I am trying to unit test an AngularJS service that uses $resource. To keep it isolated, I would like to use Jasmine's spyOn and spy on the $resource's query() method. In my controller, I would like to be able to use the short form of query() where…
Matt
  • 823
  • 1
  • 8
  • 17
0
votes
1 answer

AngularJS and Jasmine testing factory

I am new to angularjs unit testing. I have a factory I am trying to spy on with jasmine and I can't figure out the syntax for the test spec. Below is the factory: app.factory('assetFactory', function ($http) { var baseAddress = "../api/"; …
steveareeno
  • 1,925
  • 5
  • 39
  • 59
0
votes
1 answer

jasmine javascript spyon object instance

So I have this JS prototype (class) that I'm trying to build jasmine tests for and cannot seem to figure out how to get these tests working. here's the important parts of the class: class Calendar extends BasicView initialize: (options) -> …
Sparkmasterflex
  • 1,837
  • 1
  • 20
  • 33
0
votes
1 answer

Testing if a controller works in angularjs using jasmine

I have some issues when I'm trying to test a method controller. So, here is my controller, named contactCtrl 'use strict'; (function () { angular.module('routerApp').controller('ContactController', function ($scope, contactRepository)…
RobertRPM
  • 137
  • 1
  • 16
0
votes
1 answer

How to spy on a class method in node-jasmine?

I have a module User - like this: module.exports = User = (function() { function User(params) { this.id = params.id; this.first_name = params.first_name || ''; this.last_name = params.last_name || ''; …
9_Dave_9
  • 694
  • 1
  • 7
  • 20
0
votes
0 answers

Unit test in angularJs with Jasmine: mock an infinite recursive function

I'm trying to unit test with Jasmine a controller with an infinite recursive function that I call at the controller creation like this: angular.module('myApp') .controller('LargeHomeCtrl', ['$scope', '$timeout', function ($scope, $timeout) { …
Simon
  • 6,025
  • 7
  • 46
  • 98
0
votes
1 answer

Spy on a local function Angular Service

I have an Angular Service using a local function and doing the following work: function myService($http,$q){ var myService = {}; var _localService = function (Table) { return Table.something; } var _getSomething = function () { return…
Sifis
  • 653
  • 5
  • 18
-1
votes
1 answer

Mocking a function within an express request for a Jest Unit test

I have a simple express application and i want to fully be able to mock it, here's what i've got so far userRoute.js const express = require("express") const router = express.Router() const db = require('./db') router.get("/users/", async (req,…
beep
  • 41
  • 3
-1
votes
1 answer

how to use spyOn on a class less component

I am trying to apply spyOn to check whether my fucntion download is called on mouse click but I am getting the error. I am already follwoing this question but still no leads. Can anyone tell me where I went wrong. I cannot figure out any…
USAF
  • 33
  • 4
1 2 3 4 5 6 7
8