Questions tagged [jasmine2.0]

Jasmine is an open source testing framework for JavaScript. It aims to run on any JavaScript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. It is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec.

Jasmine is an open source testing framework for JavaScript. It aims to run on any JavaScript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. It is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec.

197 questions
0
votes
1 answer

Jasmine 2.0 unit testing for angularjs factory

I am new to writing jasmine test cases for angularJS factory. I want to test the entire factory, but I'm unable to fetch getKeys. Here's my factory. My Factory is: 'use strict'; var a11yModule = angular.module('TestModule',…
0
votes
0 answers

JS Tests in Visual Studio fail with Chutzpah but succeed when executed in browser

I am facing a problem with Chutzpah in Visual Studio 2017. I have some Tests for my jQuery Code, which run successfully in the Browser (Firefox, Edge & Chrome), but fail when running them in VS with Chutzpah. First of all my setup: Jasmin Version…
Torben
  • 438
  • 1
  • 7
  • 22
0
votes
0 answers

Call on $state.go not working in unit test

I work on an app based on Angular 1.5, angular-ui-router and WebPack for which I want to make unit tests on module declaration part, especially on state configuration (I want to test source code of resolve part). All others unit tests of my app are…
Gaëtan Maisse
  • 12,208
  • 9
  • 44
  • 47
0
votes
1 answer

Can I spy on a dependency to the system under test - even if it is not a direct dependency of the SUT?

My question relates to Jasmine. Say I have the following graph of dependencies in an application: SystemUnderTest --> Dependency1 --> Dependency2 --> DependencyN Can I spy on DependencyN even if it is not a direct dependency to the system under…
balteo
  • 23,602
  • 63
  • 219
  • 412
0
votes
3 answers

Timeouts occur on different platforms when running e2e test using protractor

I am using protractor to perform e2e tests but i keep getting this error message: - Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. I have increased the timeout limit to 60 seconds and i…
0
votes
2 answers

jasmine-expect cannot find jest, jasmine v2.x, or jasmine v1.x

I'm trying unit test with jasmine-expect. However I keep getting the error: jasmine-expect cannot find jest, jasmine v2.x, or jasmine v1.x I have installed the latest version of jasmine. What am I missing? package.json { "name": "js", …
lomse
  • 4,045
  • 6
  • 47
  • 68
0
votes
1 answer

Jasmine: How to test a user input?

I wrote the following html file:

HELLO WORLD

CrazySynthax
  • 13,662
  • 34
  • 99
  • 183
0
votes
2 answers

Testing two resolved promises with Angular/Jasmine

I have a service called myHttp that returns a promise, and a controller that calls myHttp twice with different parameters. To test the controller, I'm attempting to mock myHttp with Jasmine spyOn like so: beforeEach(inject(function($controller,…
ps0604
  • 1,227
  • 23
  • 133
  • 330
0
votes
0 answers

How to redefine browser builtin variable to certain value to test a module?

How could I test this using Jasmine ? /** Function for detecting if user uses IE-Browser */ Cemcloud.detectIE = function () { var ua = window.navigator.userAgent; var msie = ua.indexOf('MSIE '); if (msie > 0) { // IE 10 or…
user7030890
0
votes
1 answer

Testing Angular/Jasmine directive cannot GET template html

I have the following Karma/Jasmine test of an Angular directive that contains a templateUrl: describe("topbar Directive", function() { var scope,element; beforeEach(module('app')); beforeEach(module('app/directives/topbar.html')); …
ps0604
  • 1,227
  • 23
  • 133
  • 330
0
votes
2 answers

Issue with jasmine spies call through

I am having trouble calling through to the actual implementation and I am getting this error: TypeError: undefined is not an object (evaluating 'GitUser.GetGitUser('test').then') ... Here are my codes: app.controller('HomeController', ['$scope',…
Ron T
  • 397
  • 1
  • 4
  • 22
0
votes
2 answers

Catching variable set in timeout in Angular/Jasmine test

In this Angular/Jasmine example I have a controller with a promise and a $timeout. The test fails because a variable set in the $timeout is undefined. Other variables not set inside the $timeout don't have this problem. Only this expect fails, the…
ps0604
  • 1,227
  • 23
  • 133
  • 330
0
votes
1 answer

Runtime unit testing in JavaScript

I've been testing JavaScript code using unit testing frameworks like jasmine and Qunit. But all these testing framework works only at load time, but I want to initiate the test cases at run time, for instance I want to test an object's value on a…
Bharath
  • 91
  • 1
  • 3
  • 11
0
votes
0 answers

Unit testing attribute angular directive with Jasmine 2

I have an attribute directive that will be used with another parent directive: function childDirective(/*injection*/) { return { restrict: 'A', replace: true, transclude: false, require: 'parentDirective', link: link }; …
amol01
  • 1,823
  • 4
  • 21
  • 35
0
votes
1 answer

Understanding spies in Typescript using Jasmine

I am trying to understand how to use Spies in Typescript using Jasmine. I have found this documentation and this example: describe("A spy", function() { var foo, bar = null; beforeEach(function() { foo = { setBar: function(value) { …
030
  • 10,842
  • 12
  • 78
  • 123