jasmine

jasmine-reporters is not generating any file

余生颓废 提交于 2019-12-08 04:15:56
问题 i'm using jasmine-reporters to generate a report after protractor finish the tests, this is my configuration file: onPrepare: function(){ var jasmineReporters = require('jasmine-reporters'); var capsPromise = browser.getCapabilities(); capsPromise.then(function(caps){ var browserName = caps.caps_.browserName.toUpperCase(); var browserVersion = caps.caps_.version; var prePendStr = browserName + "-" + browserVersion + "-"; jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter(

What are the methods we can use to wait for an angular site to be loaded in order to test it with protractor?

混江龙づ霸主 提交于 2019-12-08 03:32:54
问题 What are the methods we can use to wait for an Angular site to be loaded in order to test it with protractor in order to avoid this error caused by jasmine : A Jasmine spec timed out. Resetting the WebDriver Control Flow ? I'm able to make the login and go to home page that test is passed, but from the second test i have problems of jasmine. 回答1: I have configured this problem by adding this function into my config file : onPrepare: function() { return browser.getProcessedConfig().then

Unit testing angular directive - very stuck

爷,独闯天下 提交于 2019-12-08 03:23:53
问题 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',

Unit test failing when function called on startup

醉酒当歌 提交于 2019-12-08 03:15:21
问题 This is an extension off a former question of mine: $httpBackend in AngularJs Jasmine unit test In my controller, the getStuff function is called on startup. This causes my unit test to fail. When I comment it out, my unit tests pass and work successfully. When uncommented, the error is: Error: Unexpected request: GET /api/stuff No more request expected My controller is: $scope.stuff = []; $scope.getStuff = function () { var url = site.root + 'api/stuff'; $http.get(url) .success(function

How to mock router state in ember + jasmine

六眼飞鱼酱① 提交于 2019-12-08 03:10:19
问题 In my jasmine test suite I want to navigate my router to the right state. Something like this: describe("The Router", function(){ beforeEach(function(){ router = App.Router.create(); router.transitionTo('foo.bar'); } }); but if I do so, I get an Cannot call method 'disconnectOutlet' of undefined error. That happens cuz I am calling bar: Ember.Route.extend({ connectOutlets: function(router, context){ router.get('applicationController').connectOutlet('bla', 'blub'); } }), at this router

解决ajax跨域几种方式

◇◆丶佛笑我妖孽 提交于 2019-12-08 01:40:28
发生跨域问题的原因: 浏览器的限制,出于安全考虑。前台可以正常访问后台,浏览器多管闲事报跨域问题,但其实前台已经访问到后台了。 跨域,协议、域名、端口任何一个不一样浏览器就认为是跨域。 XHR(XMLHttpRequest)请求,因为ajax是XHR请求,浏览器就会捕捉跨域问题。 解决思路: 让浏览器不做限制,指定参数,让浏览器不做校验,但该方法不太合理,它需要每个人都去做改动。 不要发出XHR请求,这样就算是跨域,浏览器也不会报错,解决方案是JSONP,通过动态创建一个script,通过script发出请求。 在跨域的角度:一种是被调用方修改代码,加上字段,告诉浏览器,支持跨域,支持调用 通过nginx代理方式,在a域名里面的的请求地址使用代理指定到b域名。 跨域解决方案: 被调用方解决:在请求响应头增加指定字段,告诉浏览器允许调用。这种解决方案的请求是直接从浏览器发送的。( 服务器端实现、NGINX配置Apache配置) 调用方解决:这是隐藏跨域的解决法案。这种跨域请求不是直接从浏览器发送的,而是从中间的http服务器转发过去的。 设置浏览器不做限制: 可以使用everyting软件搜索浏览器的全路径,使用dos切换到此路径下 cd C:\Users\Administrator\AppData\Local\Google\Chrome\Application 输入 chrome

Protractor+AngularJS+Jasmine - test press and hold item

巧了我就是萌 提交于 2019-12-08 01:09:03
问题 Very new with AngularJS and Protractor, but I think I am going to the right direction so far. My site has a list of items when you click and hold the item for X seconds, it opens a modal window. How can I simulate that behavior in Protractor/Jasmine? I know there is the "click()" event, but I want the "click and hold" event I am sure there is someone that knows how to simulate that. Big thanks in advance! 回答1: The idea is to use mouseDown() first: /** * Presses a mouse button. The mouse

How can I resolve Angular unit test error: “An error was thrown in afterAll\n[object ErrorEvent] thrown”

被刻印的时光 ゝ 提交于 2019-12-08 00:42:42
问题 When I run ng test command in my angular project has error, it gives an error like that 10% building modules 1/1 modules 0 active04 12 2018 11:29:43.408:WARN [karma]: No captured browser, open http://localhost:9876/ 04 12 2018 11:29:43.414:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/ 04 12 2018 11:29:43.414:INFO [launcher]: Launching browser Chrome with unlimited concurrency 04 12 2018 11:29:43.418:INFO [launcher]: Starting browser Chrome 04 12 2018 11:29:53.540:WARN

Mocking an angular service in Protractor

夙愿已清 提交于 2019-12-07 23:25:39
问题 I'm trying to use Protractor's addMockModule to insert mock data in my end-2-end test. My test is supposed to go to a web site, find a button by css-class and click it. The button click calls the function dostuff() in MyService, which fetches data from the backend. My code so far: describe('should display validation error', function () { it('should work', function () { browser.get('http://my.url'); browser.addMockModule('MyService', function () { // Fake Service Implementation returning a

How to use jsdom.jQueryify with jasmine-node?

人盡茶涼 提交于 2019-12-07 22:58:34
问题 Is it possible to user jasmine-node with the jQueryify feature of jsdom? What I'm trying to do is use NodeJS to test some JavaScript that depends on the presence of the DOM. Here is a reduced case of what I tried. When I run the script, jasmine-node recognizes the spec, but doesn't run the expect() : var fs = require('fs'), jsdom = require('jsdom'), window = jsdom.createWindow(), jasmine = require('jasmine-node') describe("jQueryify", function() { it('should run the test!', function () {