jasmine

How do I test an externally served app using Testacular + AngularJS

社会主义新天地 提交于 2019-12-05 03:24:59
问题 I have an app running on http://localhost:6543 - it's a Pyramid app. This app serves the AngularJS app at / This app uses socket.io itself The question is: is it possible to test that application using those tools ? I have this in my scenario.js file: beforeEach(function() { browser().navigateTo('http://localhost:6543/'); }); but the moment I launch testacular (with run or start ), I get this error message: Chrome 23.0 registration: should delete all cookies when user clicks on "remove all"

Angularjs - simulate touch event in Protractor e2e test

牧云@^-^@ 提交于 2019-12-05 03:24:04
I use Protractor with Jasmine for my mobile Angularjs app. I want to test a touch event (touchStart / touchEnd etc...) on a particular element. Something like: it('should play video', function(){ var poster = by.css('.video-poster'); element(poster).??? //Simulate touch event here }); Meligy Update: Since Protractor returns a Selenium element finder not an angular element, you'll have to use the executeScript() function to call a JavaScript method on it, like: var poster = element(by.css('.video-poster')); browser.executeScript( 'angular.element(arguments[0]).triggerHandler("touchstart");',

Is there any way to use Jasmine default matchers within custom matchers?

余生长醉 提交于 2019-12-05 03:23:20
I have a custom matcher in some Jasmine test specs of the form: this.addMatchers({ checkContains: function(elem){ var found = false; $.each( this.actual, function( actualItem ){ // Check if these objects contain the same properties. found = found || actualItem.thing == elem; }); return found; } }); Of course, actualItem.thing == elem doesn't actually compare object contents- I have to use one of the more complex solutions in Object comparison in JavaScript . I can't help but notice, though, that Jasmine already has a nice object equality checker: expect(x).toEqual(y) . Is there any way to use

Jenkins integration with Jest

旧街凉风 提交于 2019-12-05 03:16:18
Is there a way to have Jenkins integration in the Javascript Jest testing framework that is built on top of Jasmine? I've tried to integrate Jest with jasmine-reporters , but didn't manage to get a JUnit XML output. I installed the reporters for Jasmine 1.3 with npm install jasmine-reporters@~1.0.0 and then in my setupTestFrameworkScriptFile : require('jasmine-reporters'); jasmine.VERBOSE = true; jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter({ savePath: "output/" })); When I run jest I get NodeJS attempt: Arguments to path.join must be strings or NodeJS attempt: Object [object

Protractor wait command is not able to wait for the bootstrap modal to appear

纵饮孤独 提交于 2019-12-05 02:16:52
Scenario: Whenever user sign in using incorrect credentials, a bootstrap modal appears for 1-2 second with message "sorry, incorrect credentials". Below is the HTML of the modal. <div class="modal-content"> <div class="modal-body note-error text-center ng-binding"> Sorry, invalid credentials! </div> </div> I need to verify if the expected error text is equal to actual error text. My code PageObject.js var errorModal = element(by.css('.modal-body.note-error.text-center.ng-binding')); this.getErrorText = function(){ var until = protractor.ExpectedConditions; browser.wait(until

How can I make jasmine.js stop after a test failure?

老子叫甜甜 提交于 2019-12-05 02:12:50
I want the runner to stop after the first failure rather than running all the tests. It's a hack, but you can do this by inserting this script before your first test; <script type="text/javascript"> // after every test has run afterEach(function () { // check if any have failed if(this.results_.failedCount > 0) { // if so, change the function which should move to the next test jasmine.Queue.prototype.next_ = function () { // to instead skip to the end this.onComplete(); } } }); </script> Jasmine's latest commit at the time of applying this was https://github.com/pivotal/jasmine/commit

Angular mock fails to inject my module dependencies

扶醉桌前 提交于 2019-12-05 01:56:01
I want to test an Angular controller for my application fooApp , defined as follow: var fooApp = angular.module('fooApp', [ 'ngRoute', 'ngAnimate', 'hmTouchEvents' ]); ... The controller, MainCtrl is defined: "use strict"; fooApp.controller('MainCtrl', function ($scope, $rootScope, fooService) { ... } So I've tested several ways to create a test, like this one: 'use strict'; describe('MainController test', function () { var scope; var controller; beforeEach(function () { angular.mock.module('ngRoute', []); angular.mock.module('ngAnimate', []); angular.mock.module('hmTouchEvents', []); angular

Check POST request payload data with Protractor

若如初见. 提交于 2019-12-05 01:49:36
问题 Let's say i have angular page with a couple of input elements and save button. After Save button is clicked POST request will be sent. I'm writing Protractor e2e test for this page. The question: How can i check with protractor POST request payload data after app is sent it or before sending? I want to be sure that my app will sent right data in POST request. 回答1: Following @Andres D's comment: yes, there is a misconception here. protractor is a tool that helps you mimic real-user

How to test AngularJS Directive with scrolling

£可爱£侵袭症+ 提交于 2019-12-05 01:45:37
I have an infinite scroll directive that I am trying to unit test. Currently I have this: describe('Infinite Scroll', function(){ var $compile, $scope; beforeEach(module('nag.infiniteScroll')); beforeEach(inject(function($injector) { $scope = $injector.get('$rootScope'); $compile = $injector.get('$compile'); $scope.scrolled = false; $scope.test = function() { $scope.scrolled = true; }; })); var setupElement = function(scope) { var element = $compile('<div><div id="test" style="height:50px; width: 50px;overflow: auto" nag-infinite-scroll="test()">a<br><br><br>c<br><br><br><br>e<br><br>v<br><br

Jasmine angularjs - spying on a method that is called when controller is initialized

我与影子孤独终老i 提交于 2019-12-05 01:42:19
问题 I am currently using Jasmine with Karma(Testacular) and Web Storm to write unit test. I am having trouble spying on a method that gets called immediately when the controller is initialized. Is it possible to spy on a method that is called when the controller is initialized? My controller code, the method I am attempting to spy on is getServicesNodeList() . myApp.controller('TreeViewController', function ($scope, $rootScope ,$document, DataServices) { $scope.treeCollection = DataServices