jasmine

Responsive design testing with PhantomJS

☆樱花仙子☆ 提交于 2020-01-01 09:39:05
问题 I have a javascript application (RequireJS with Backbone ) which I am testing using PhantomJS with Jasmine. After much pain I finally have simple tests running. I am using a test runner based on the one found here run-jasmine.js. My application is responsive in that as the viewport width changes, the widths of various DOM elements will also change. I am aware that I can set the viewport width in 'run-jasmine.js' when I create the 'page' for testing. What I would like to know is.....Are you

Testing a debounced function in AngularJS with Jasmine never calls the function

泪湿孤枕 提交于 2020-01-01 08:28:13
问题 I have a method in a service that uses underscore's debounce. Inside that method is a call to a method on a different service. I'm trying to test that the different service is called. In my attempts to test the debounced method, the different services' method is never called, and jasmine fails with: "Expected spy aMethod to have been called." I know for a fact that it IS called (it logs to console in chrome), it's just called AFTER the expectation already failed. So... (preferably) without

Ionic Jasmine : env.stopOnSpecFailure is not a function after compiled successfully

回眸只為那壹抹淺笑 提交于 2020-01-01 08:05:12
问题 Using Ionic with jasmine-karma, while run test, getting success compile but in jasmine dashboard getting empty screen with error in console. Following tutorial : https://leifwells.github.io/2017/08/27/testing-in-ionic-configure-existing-projects-for-testing/ "ts-loader": "^4.1.0", "jasmine-core": "^2.99.1" Error Messages : TypeError: env.stopOnSpecFailure is not a function at adapter.js:26 Error: Module build failed: TypeError: Cannot read property 'afterCompile' of undefined 回答1: The failure

Protractor + AngularJS + Jasmine get output results on xml file

大城市里の小女人 提交于 2020-01-01 05:40:31
问题 I'm trying to export protractor results to xml files, i found this great link on web: https://github.com/angular/protractor/issues/60 After running : npm install jasmine-reporters i added the following lines to my protracotr config file: require('jasmine-reporters'); jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter( 'C:\temp\test', true, true)); and i get the following error: jasmine.console_reporter.js:2 if (! jasmine) { ^ ReferenceError: jasmine is not defined i attached here my

what done() is for and how to use it ( protractor, jasmine)

三世轮回 提交于 2020-01-01 05:28:31
问题 it('should for something', function check(done) { browser.sleep(2000); $('.csTx').isPresent().then(function(result) { if(result) { done(); } else { xPage.clickBack(); check(done); } }) }, 30000); Can someone explain how done() works and what this is for. I googled it but cannot find any information that would be easy enough for me to understand. I am automating with protractor and jasmine. please consider the above code. 回答1: You need to use done if your test creates a parallel TaskQueue in

karma.conf.js automatic file ordering?

不羁岁月 提交于 2020-01-01 05:03:34
问题 I have a large angularjs project ordered by features. I'd like to setup unit testing but I'm having trouble getting the karma.conf.js file ordering setup. I tried specifying a simple glob pattern like **/*.js but many of my modules failed to load due to the ordering that they're included in Karma when ran. As I understand, it's alphabetical, first match. I was able to resolve this by manually figuring out the ordering by doing something like this: // list of files / patterns to load in the

karma.conf.js automatic file ordering?

ε祈祈猫儿з 提交于 2020-01-01 05:03:08
问题 I have a large angularjs project ordered by features. I'd like to setup unit testing but I'm having trouble getting the karma.conf.js file ordering setup. I tried specifying a simple glob pattern like **/*.js but many of my modules failed to load due to the ordering that they're included in Karma when ran. As I understand, it's alphabetical, first match. I was able to resolve this by manually figuring out the ordering by doing something like this: // list of files / patterns to load in the

Jasmine can't spy on event handler?

烂漫一生 提交于 2020-01-01 04:37:10
问题 Trying to test that an event handler gets called on a clicked element with Jasmine. Have a "Pad" object that contains a DOM element "PadElement", which gets clicked. The event handler is a method on the Pad object: GRAPH.Pad = function(graphDiv, graph) { this.graph = graph; this.clickHandler = function(e) { console.log('padElement clickHandler called'); //this.graph.createVertex(e.clientX, e.clientY); }; this.padElement = GRAPH.padElement(graphDiv, this.clickHandler); } GRAPH.padElement =

Jasmine 2.0 rc* waits is not defined

六月ゝ 毕业季﹏ 提交于 2020-01-01 04:35:08
问题 Just upgraded to jasmine 2.0 rc5 from 1.3 and now all my tests that used waits() are broken because the waits() and waitsFor() function are undefined. I can't seem to find any reference to that anywhere online, is anyone aware of what is the new API to replace wait() ? 回答1: Well, the usage syntax for asynchronous calls changed. You can easily see the differences between the two versions in its documentations: Jasmine 1.3 Asynchronous support uses waitsFor() and run() functions. According to

Error: Timeout - Async callback was not invoked within timeout specified… .DEFAULT_TIMEOUT_INTERVAL

烂漫一生 提交于 2020-01-01 02:48:32
问题 I have an angular service class : - angular.module('triggerTips') .service('userData', function ($rootScope, $http, $log, $firebase) { this._log = { service : 'userData' }; // Synchronized objects storing the user data var config; var userState; // Loads the user data from firebase this.init = function(readyCallback) { var log = angular.extend({}, this._log); log.funct = 'init'; var fireRef = new Firebase('https://XYZfirebaseio.com/' + $rootScope.clientName); config = $firebase(fireRef.child(