jasmine-jquery

Can't find variable: loadFixtures

老子叫甜甜 提交于 2019-12-11 13:22:09
问题 I am using karma, jasmine and phantomjs for my project and when I am executing start karma; I am getting following error: PhantomJS 1.9.7 (Linux) View:: Login guestRegistration Should call the guestRegistration event when btn-grey is clicked FAILED ReferenceError: Can't find variable: loadFixtures at /apps/devops/jenkins/home/jobs/UIMod-Jasmine-Karma/workspace/WebContent/test/javascript/spec/login.view.spec.js:84 ReferenceError: Can't find variable: spyOnEvent at /apps/devops/jenkins/home

ReferenceError: Can't find variable: $ when running JasmineHeadlessWebkit

↘锁芯ラ 提交于 2019-12-11 08:27:34
问题 I've been trying to find an answer to this at least for the last two hours without any luck. I hope someone here might be able to help. I'm getting this ReferenceError: Can't find variable: $ when running my Jasmine specs using the JasmineHeadlessWebkit. The weird thing is, this only happens when I say $ -> game.init() in my game.coffee file. I can use the $ without any problems further down game.coffee . For example: window.game = init: -> $('.gamelayer').hide() $('#gamestartscreen').show()

Testing backbone views with jasmine

允我心安 提交于 2019-12-11 05:21:40
问题 I am trying to test my backbone views with jasmine. I use underscore library to generate templates for the backbone views. For testing purposes I use jasmine jasmine-jquery I am unable to load the fixtures in the jasmine tests as the views have embeded ruby. Here is my code Backbone view AlbumView = Backbone.View.extend({ template: _.template($('#album-template').html()), render: function() { $('#albums').append(this.template(this.model.attributes)); } }); This view uses the following

Jasmine.js Testing - spy on window.open

邮差的信 提交于 2019-12-10 14:29:10
问题 JS var link = this.notificationDiv.getElementsByTagName('a')[0]; link.addEventListener('click', function (evt){ evt.preventDefault(); visitDestination(next); }, false); } var visitDestination = function(next){ window.open(next) } Spec var next = "http://www.example.com" it( 'should test window open event', function() { var spyEvent = spyOnEvent('#link', 'click' ).andCallFake(visitDestination(next));; $('#link')[0].click(); expect( 'click' ).toHaveBeenTriggeredOn( '#link' ); expect( spyEvent )

Can't get $.ajax.mostRecentCall to work with jasmine 2.0.2

点点圈 提交于 2019-12-10 12:34:23
问题 Having real trouble getting a simple example to work. I am using this example taken from https://gist.github.com/Madhuka/7854709 describe("Test for spies", function() { function sendRequest(callbacks, configuration) { $.ajax({ url: configuration.url, dataType: "json", success: function(data) { callbacks.checkForInformation(data); }, error: function(data) { callbacks.displayErrorMessage(); }, timeout: configuration.remainingCallTime }); } it("should make an Ajax request to the correct URL",

BeforeAll and AfterAll in javascript test cases

天涯浪子 提交于 2019-12-08 18:16:31
问题 I want do something before all tests, then after? What is the best way to organize my code? For example: backup some variables -> clear them -> test something -> restore backups. 'beforeEach' and 'afterEach' are too expencive. Thanks! 回答1: A pretty simple solution: describe("all o' my tests", function() { it("setup for all tests", function() { setItUp(); }); describe("actual test suite", function() { }); it("tear down for all tests", function() { cleanItUp(); }); }); This has the advantage

jasmine-jquery loadFixtures with Jasmine 2.0 won't work

吃可爱长大的小学妹 提交于 2019-12-05 00:51:47
问题 I've spent about a day debugging this, and I'm at a loss. It looks like something isn't working in jasmine-jquery 2.0.2. I'm updating from Jasmine 1.3.1 and jasmine-jquery 1.5 to the newest versions. I am getting various failures depending on how I attempt to load fixtures. I get " Fixture could not be loaded: ./ExposureWorksheetFixture.html (status: parsererror, message: Invalid XML" after I tweaked jasmine-jquery to supply parameters to the ajax.fail() method. Another effect I have, when I

Javascript JsTestDriver Jasmine & Jasmine-jquery

笑着哭i 提交于 2019-12-03 14:48:59
问题 I have lots of Jasmine unit tests, that are running unit tests for Javascripts code. They are using Jasmine-jquery plugin to do DOM manipulation. they use loadFixture, to load fixtures of HTML I tried to automate those unit tests, using JsTestDriver, with JasmineAdapter But all tests involve DOM-jquery manipulation are not passing? Is there something wrong with that? Is there a way to use Jasmine-jquery with JsTestDriver? 回答1: I will answer myself because I found a solution for this problem.

How to assert a spy is invoked with event on click using jasmine?

孤人 提交于 2019-12-03 11:21:57
I'm writing a simple click handler and need the event passed in (like so) Thing = function($){ var MyObject = function(opts){ this.opts = opts; }; MyObject.prototype.createSomething = function(){ var that = this; $('#some_dom_element').live('click', function(e) { that.doStuff(e); }); }; MyObject.prototype.doStuff = function(e) { //do some javascript stuff ... e.preventDefault(); }; return MyObject; }(jQuery); Currently in my jasmine spec I've got something to spy on the function I expect gets invoked (but since it's called with e -not without args- my assertion is failing) it ("live click

Javascript JsTestDriver Jasmine & Jasmine-jquery

爱⌒轻易说出口 提交于 2019-12-03 03:38:47
I have lots of Jasmine unit tests, that are running unit tests for Javascripts code. They are using Jasmine-jquery plugin to do DOM manipulation. they use loadFixture, to load fixtures of HTML I tried to automate those unit tests, using JsTestDriver, with JasmineAdapter But all tests involve DOM-jquery manipulation are not passing? Is there something wrong with that? Is there a way to use Jasmine-jquery with JsTestDriver? I will answer myself because I found a solution for this problem. The problem was Jasmine-Jquery is using ajax to load the html fixture, and it uses a relative path, assuming