jasmine

Are test cases in Jasmine 2.0 run in parallel

一世执手 提交于 2020-01-24 02:20:28
问题 Are tests in Jasmine 2.0 run in parallel? In my experience they aren't but the article , referenced by Jasmine.js: Race Conditions when using "runs" suggests that Jasmine does run them in parallel so I wondered if I was writing my tests incorrectly. Here is a set of tests that I would expect to execute in 1 second instead of 4 seconds. describe("first suite", function() { it("first test", function(done) { expect(true).toBeTruthy(); setTimeout(done, 1000); }); it("second test", function(done)

TypeError: jasmine.getEnv().currentSpec is null

耗尽温柔 提交于 2020-01-24 02:03:48
问题 When I try to run my jasmine specs, I get TypeError: jasmine.getEnv().currentSpec is null in http://localhost:8888/__JASMINE_ROOT__/jasmine.js (line 498) No idea why, not even sure where to begin looking. Line 498 is: return jasmine.getEnv().currentSpec.expect(actual); I've been doing jasmine for several months now, but not on this project. I've never seen this happening before. So, where do I start? (This is jasmine gem in a rails 3.x project) 回答1: I was seeing the same error. I had an

$httpBackend is undefined although angular-mock is included

只愿长相守 提交于 2020-01-23 21:39:46
问题 This is my test. I get error that $httpBackend is undefined. describe("Objects Service", function () { var $httpBackend, $rootScope, scope, datacontext, config; beforeEach(function () { module('agApp'); }); beforeEach(inject(function ($rootScope, _$httpBackend_, _datacontext_, _config_) { scope = $rootScope.$new(); datacontext = _datacontext_; $httpBackend = _$httpBackend_; config = _config_; })); it("should call right API adress to get all objects", function () { $httpBackend.whenGET('/api

Jasmine unit test for angular service In controller

£可爱£侵袭症+ 提交于 2020-01-23 13:17:09
问题 I'm new to jasmine framework. I've gone through some tutorials and learned and started writing unit tests. 'facing one issue here is the description. I have a controller where i can invoke a service call to get the data. See the code below. $scope.getEmpInfo = function() { EmpService.getInfo($scope.empid) .then(function(data) { $scope.empData = data; $scope.populateEmpData($scope.empData); }, function(reason) { //do nothing } } Now, i want to write a unit test for the above method. Im able to

Why does my Jasmine spec think my Angular module is undefined

那年仲夏 提交于 2020-01-23 12:05:58
问题 Why does my Jasmine spec think my Angular module is undefined? I've added a line of code setting a boolean to true below the actual module code, and then I console.log it from within the spec, and it indicates true. I've also tried changing the module so it is not an ultra-scope (my term) or IIFE, but that has no effect. The gist of the error message is Expected undefined to equal <jasmine.any(Object)>. Spec runner: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text

JasmineNodeOpts - Printing Protractor Test Results

半腔热情 提交于 2020-01-23 08:06:07
问题 Background : I'm using Jasmine as my test framework for Protractor, I've been using jasmine spec reporter for reporting. Yesterday I slightly changed my jasmineNodeOpts parameters in my protractor conf.js to include the print() function i.e. jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 120000, includeStackTrace : true, isVerbose : true, print: function () {} }, I added this print function because I learned it would remove the . before each report. For example, my test reports

toBe(true) vs toBeTruthy() vs toBeTrue()

浪子不回头ぞ 提交于 2020-01-22 04:04:47
问题 What is the difference between expect(something).toBe(true) , expect(something).toBeTruthy() and expect(something).toBeTrue() ? Note that toBeTrue() is a custom matcher introduced in jasmine-matchers among other useful and handy matchers like toHaveMethod() or toBeArrayOfStrings() . The question is meant to be generic, but, as a real-world example, I'm testing that an element is displayed in protractor . Which matcher should I use in this case? expect(elm.isDisplayed()).toBe(true); expect(elm

accessing $scope from unit test file when using the vm “ControllerAs” syntax from AngularJS HotTowel

馋奶兔 提交于 2020-01-20 17:09:51
问题 See here for example: http://www.johnpapa.net/angularjss-controller-as-and-the-vm-variable/ As the title suggests, I'm following along on this tutorial [http://tech.pro/tutorial/1473/getting-started-with-angularjs-unit-testing] to setup unit testing and all is fine EXCEPT for the fact I can't seem to access the vm variable as my $scope . dashboard.js var controllerId = 'dashboard'; angular.module('app') .controller(controllerId, ['common', 'datacontext', dashboard]); function dashboard(common

accessing $scope from unit test file when using the vm “ControllerAs” syntax from AngularJS HotTowel

拈花ヽ惹草 提交于 2020-01-20 17:09:50
问题 See here for example: http://www.johnpapa.net/angularjss-controller-as-and-the-vm-variable/ As the title suggests, I'm following along on this tutorial [http://tech.pro/tutorial/1473/getting-started-with-angularjs-unit-testing] to setup unit testing and all is fine EXCEPT for the fact I can't seem to access the vm variable as my $scope . dashboard.js var controllerId = 'dashboard'; angular.module('app') .controller(controllerId, ['common', 'datacontext', dashboard]); function dashboard(common

How to mock $http.post method that has been called in other service method in jasmine?

孤街浪徒 提交于 2020-01-17 07:42:33
问题 I have and angular service that I want to test. In one of his methods I am using $http of angular service. I am simply want to mock that function (to be more specific mock $http.post function) that would return whatever I want and inject this mock to my service test. I am tried to find solution and I found $httpBackend but I am not sure that this could help me. MyService looks like that: angular.module('app').service('MyService' , function (dependencies) { let service = this; service