jasmine

How to get jasmine tests to load data and execute in the right order

*爱你&永不变心* 提交于 2019-12-22 08:38:15
问题 I'm using Jasmine (2.3.2) and Protractor (2.5.1) for my UI tests. I need to load in data and generate tests for each item from that array. I have a function ( checkItem ) that creates a new describe function for each item and checks certain properties on that object. This is a very simplified version of my code and there are other tests that run before these. If I call checkItem in a describe statement, itemsArr isn't defined yet. So I'm not sure how to get the data loaded and create dynamic

Writing a log file for Protractor/Jasmine tests without using command line

这一生的挚爱 提交于 2019-12-22 08:14:24
问题 I'm aware that if you were to do something like protractor config.js > file.log all the console output would be written to file.log. Is there a way to do this/access that output from within the tests though so that I can use a dynamic path that's created with my reporting tool? And also in a way that I don't lose the console output. Edits: To elaborate a little further, I'm not only interested in console.log output. I'm interested in everything that comes from what seems to be protractors

angular + jasmine + mock $stateParams in a directive

南笙酒味 提交于 2019-12-22 08:08:34
问题 What is the best approach to mock $stateParams in a directive? $stateParam members will be changed according to the test. I can easily mock $stateParams in a controller using $controller('ctrl', $stateParams) but dont know how to modify $stateParams that gets injected into the directive. I've gone the route of decorating $stateParams with the below but can only declare that when i create the module. as i mentioned, $stateParam members will change many times through the different tests.

Angular/Jasmine testing with deffered promises

时光总嘲笑我的痴心妄想 提交于 2019-12-22 08:03:53
问题 I am testing a controller using a combination of angular and jasmine, and am not completely sure about using deffered promises. This is my spec code. describe('Controller Tests', function(){ var scope, searchAPI; beforeEach(function(){ var mockSearchAPI = {}; module('myApp', function($provide){ $provide.value('searchAPI', mockSearchAPI); }); }); inject(function($q){ var testData = {"message":"hi"}; mockSearchAPI.executeSearch = function(){ var defer = $q.defer(); defer.resolve(testData);

How does the createSpy work in Angular + Jasmine?

自作多情 提交于 2019-12-22 07:08:17
问题 I made a simple demo of a factory and I am trying to test this using jasmine . I am able to run the test but I am using the spyOn method. I would rather use jasmine.createSpy or jasmine.createSpyObj to do the same test. Could someone help me to refactor my code so that uses these methods instead in my example? http://plnkr.co/edit/zdfYdtWbnQz22nEbl6V8?p=preview describe('value check',function(){ var $scope, ctrl, fac; beforeEach(function(){ module('app'); }); beforeEach(inject(function(

Testing a component, which depends on a route param

為{幸葍}努か 提交于 2019-12-22 06:56:01
问题 I have a question about testing a routed component in angular2. Here is a simple component, which depends on a route with a parameter 'foo' . The attribute foo in the component will be set to the value of the parameter. import {Component, OnInit} from '@angular/core'; import {ActivatedRoute, Params} from '@angular/router'; @Component({ selector: 'my-component', templateUrl: './my-component.html' }) export class MyComponent implements OnInit { foo: string; constructor( private route:

How to spy jQuery AJAX request?

时光怂恿深爱的人放手 提交于 2019-12-22 06:48:56
问题 The following two ways of implementing an ajaxRequest (1) (2) should be equivalent. Having said that: Why does the unit test (3) that verifies the callback was executed, succeeds in (1) and fails in (2)? How should I rewrite the test (3) to spy on the success callback in (2)? If I try to stub jQuery.ajax using sinon and the code (2) I get an error. How should I fix it? Please, see the comments in code (3) for more details. (1) ajaxRequest: function (message, callback) { return $.ajax({ url:

test not running on karma/jasmine/require.js 'There is no timestamp for *lib*!' error

空扰寡人 提交于 2019-12-22 06:47:15
问题 I change the code, extend some functionality and add new unittest for that. Now, when I run my unit tests with karma (test framework - jasmine ), it throw me an error 'There is no timestamp for /libs/angular-bootstrap/ui-bootstrap-tpls.js!' Uncaught Error: Script error for: angular-bootstrap http://requirejs.org/docs/errors.html#scripterror at http://localhost:9876/base/node_modules/karma-requirejs/lib/require.js?1379984163000:138 What I'm doing wrong? 回答1: It was my mistake completely. when

Angularjs injected controller empty when testing with Jasmine

江枫思渺然 提交于 2019-12-22 06:32:25
问题 I am currently working with Angular and using Karma and Jasmine to make the testing. The filters, for example are injected to the main module and can be tested without any problem, but when I try to test the controllers I get an empty object after the injection. Here is the code of my main module: (function () { 'use strict'; var dependencies = []; angular.module('myApp', dependencies) }()); The controller that I am to test: (function () { 'use strict'; angular.module('myApp') .controller(

Internet Explorer Selenium protractor e2e tests

≯℡__Kan透↙ 提交于 2019-12-22 05:54:22
问题 I would like to add to our CI build process some e2e tests. I have already added them against chrome + firefox (as the simplest ones). But I really want to do it for several IE versions. How is it possible to inject it in build process on linux/mac? I found such article: http://elgalu.github.io/2014/run-protractor-against-internet-explorer-vm/ But looks like it is not 100% what I need. Could some one provide a simple configuration sample? 回答1: You would need a selenium server, either your own