jasmine

Unit testing angular directive - very stuck

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 00:49:30
I am having a ton of trouble testing my directive. Right now I am stuck with these two errors Test 'pbImagePicker template:should render HTML based on scope correctly' failed TypeError: 'undefined' is not a function (evaluating 'element.click') Test 'pbImagePicker element.click():should assign data from resolved promise when clicked' failed TypeError: 'undefined' is not a function (evaluating 'scope.$new(true)') Directive: angular.module('pb.campaigns.directives') .directive('pbImagePicker', ['$window', '$document', function ($window, $document) { return { restrict: "E", template: '<img data

Is there a way to run protractor tests in parallel by opening a browser instance for each test?

吃可爱长大的小学妹 提交于 2019-12-07 00:33:24
问题 I am facing synchronisation issues with my protractor tests and I would like to run my tests in parallel in contrast to my actual settings. In fact at the moment my tests run one after the other. I know how to this with TestsNG not sure how to do it with Jasmin Framework? 回答1: Since 0.19.0 version of Protractor, you can run tests in parallel using the multiCapabilities option: protractor.conf.js multiCapabilities: [{ 'browserName': 'chrome' }, { 'browserName': 'chrome' }] from Browser setup -

Coffeescript + Unit Testing : Global Variables?

笑着哭i 提交于 2019-12-07 00:24:49
问题 I'm trying to use Jasmine for unit testing for a small application written in coffeescript. I've found many sources saying that unit testing can be done perfectly well on JS compiled from coffeescript. How do you access the data and logic of the JS code, if everything is wrapped in an anonymous function to avoid polluting the name space? Is the only solution to run the compiler with the -b flag every time? 回答1: You should test against the public interface that you expose from your

Jasmine won't load javascript files from asset pipeline

你。 提交于 2019-12-06 23:53:43
问题 I'm developing a gem and I've installed Jasmine https://github.com/pivotal/jasmine-gem/ All of my required JS files are in my manifest file at app/assets/javascripts/application.js //= require underscore //= require backbone //= require_tree .//vendor //= require_tree .//custom //= require_tree .//templates //= require_tree .//models //= require_tree .//collections //= require_tree .//views And my jasmine.yml file references that: src_files: - 'app/assets/javascripts/application.js' But none

Unable to get property then of undefined?

我们两清 提交于 2019-12-06 23:41:01
Trying to run a unit test for my angular httpbased service: angular.module('myApp').factory('httpService',function($http) { return { sayHello:function(usr){ $http.get('/api/doit').then( function(result){ return 'hello '+usr; }); } } }); This is the test: it('should say hello from httpservice', function() { var returnData = 'hello Tomss'; httpBackend.expectGET('/api/doit').respond(returnData); var returnedPromise = httpService.sayHello('Tom'); var result; returnedPromise.then(function(response) { result = response; }); httpBackend.flush(); expect(result.data).toEqual('hello Tom'); }); I get an

How should I access an element's angularjs $ngModelController in a jasmine unit test?

二次信任 提交于 2019-12-06 22:48:39
问题 I'm currently using directiveElement.data("$ngModelController") to get access to the element's $ngModelController , as in the following example. describe("directiveElement", function () { it("should do something with ngModelController", inject(function($compile, $rootScope) { var directiveElement = $compile("<input ng-model="myNgModel" customDirective type="text"></input>")($rootScope); $rootScope.$digest(); var ngModelCtrl = directiveElement.data("$ngModelController"); ngModelCtrl.

How to run a single test file with Karma/Jasmine?

ぐ巨炮叔叔 提交于 2019-12-06 19:43:31
问题 I'm using Karma and Jasmine for testing my Angular JS code. I managed to run all the tests in my project using Karma, but if I try to run just a single file I'm getting the following error: ReferenceError: describe is not defined . Is it possible to run just a single test file and if yes then how? P.S. I'm using Intellij IDEA. 回答1: Although it's not ideal, you can replace describe (and it ) with fdescribe (and fit ) so only those tests will be executed On the other hand, xdescribe / xit

Angular2 - http call Code coverage

北慕城南 提交于 2019-12-06 19:36:46
问题 My components.ts is, getHomePageData() : void{ this.homeservice.getHomePageData() .subscribe( data => { //console.log("response status ################### "+data.status); //console.log("getUserData response ************ \n"+JSON.stringify(data)); this.defaultFacilityId = data.response.defaultFacilityId; this.defaultFacilityName = data.response.defaultFacilityName; this.enterpriseId = data.response.enterpriseId; this.enterpriseName = data.response.enterpriseName; this.facilityList = data

how to mock ngrx selector in a component

前提是你 提交于 2019-12-06 19:04:38
问题 In a component, we use a ngrx selector to retrieve different parts of the state. public isListLoading$ = this.store.select(fromStore.getLoading); public users$ = this.store.select(fromStore.getUsers); the fromStore.method is created using ngrx createSelector method. For example: export const getState = createFeatureSelector<UsersState>('users'); export const getLoading = createSelector( getState, (state: UsersState) => state.loading ); I use these observables in the template: <div class=

App folder is not loading in Ext.appliation when i try to test using jasmine

随声附和 提交于 2019-12-06 19:04:23
问题 I am trying to implement jasmine in my application(Ext js 5)for unit testing. For that i have created app-test file. Ext.require('Ext.app.Application');Ext.Loader.setConfig({enabled:true}); Ext.onReady(function() { var Application = Ext.create('Ext.app.Application', { name: 'epmct', appFolder:'app', launch: function() { Ext.create('epmct.view.vpp.dashboard.VppDashboardMainPage'); } }); }); When i run the application throught specrunner.html(File to start unit testing ) I am getting error