qunit

Excluding files from being deployed with Capistrano while still under version control with Git

那年仲夏 提交于 2019-12-10 12:43:14
问题 I want to start testing the JavaScript in my Rails apps with qUnit and I'm wondering how to keep the test JavaScript and test runner HTML page under version control (I'm using Git, of course) but keep them off the production server when I deploy the app with Capistrano. My first thought is to let Capistrano send all the code over as usual including the test files, and write a task to delete them at the end of the deployment process. This seems like sort of a hack, though. Is there a cleaner

How to test event listeners using QUnit

感情迁移 提交于 2019-12-10 11:52:13
问题 I'm using pure Javascript (no JQuery) and I'm trying to get QUnit to test my function that is only invoked via an event, i.e. it's an event listener. So the function I wish to test is of the form: (function() { function the_one_i_want_to_test() { // do stuff } window.addEventListener('load', function() { var some_element = ...; some_element.addEventListener('click', the_one_i_want_to_test); }); })(); I know I could expose the function to test it, but it is only ever used as an event listener

Does phantomJS support geolocations?

青春壹個敷衍的年華 提交于 2019-12-10 03:17:13
问题 I'm trying to run qunit test cases with PhantomJS. One of my tests are hanging in when phantomJS try to access the navigator.geolocation function of DOM. same test is working fine in the browser, just hangs in the console with phantomJS. doe phantomJS support geolocations ? any suggestion? breaks in the following if condition if(navigator.geolocation) { window.navigator.geolocation.watchPosition(updateLocation, null, { frequency: 3000 }); } 回答1: No. Simply check the features.js example.

avoid / capture / verify a Javascript alert when testing a method that displays one with qunit

萝らか妹 提交于 2019-12-09 12:17:19
问题 I'm just starting using Qunit and would like to know whether is there a way to capture/verify/omit alerts, For example: function to_test() { alert("I'm displaying an alert"); return 42; } and then have something like: test("to_test", function() { //in this case I'd like to test the alert. alerts("I'm displaying an alert", to_test(), "to_test() should display an alert"); equals(42, to_test(), "to_test() should return 42" ); // in this case I'd like to omit the alert }); I'm open to the

How to detect when all tests within a QUnit module is completed?

你说的曾经没有我的故事 提交于 2019-12-08 04:13:31
问题 For the purposes of test sequencing as well as preventing a test being interrupted. Also, is there any way to stop a module or test midway and reset QUnit (including all history results)? QUnit.moduleDone was the only thing I tried for testing module complete. But it applies for every single test within the module, not just the module as a whole. 回答1: It depends on whether QUnit is running when the tests are declared. If you stop it, declare all the tests, then start it the moduleDone

Uncaught TypeError: Cannot call method 'extractId' of undefined Ember Data while running QUnit tests

五迷三道 提交于 2019-12-07 18:26:19
问题 I'm getting Uncaught TypeError: Cannot call method 'extractId' of undefined while running integration tests with QUnit. The failing test: module "Points", setup: -> App.reset() Ember.run App, App.advanceReadiness test "Index", -> visit("/points").then -> ok(exists(".title:contains('POINTS')"), "Retrieved title of points section") App.Point.find().then (points) -> equal(find(".listContainer li").length, points.get('length') , "Retrieved correct number of points") Running this test in isolation

qUnit: Twitter Bootstrap modals writing outside of qunit-fixture

拈花ヽ惹草 提交于 2019-12-07 18:23:27
问题 I'm having a difficult time writing qUnit tests for a project that uses Twitter's Bootstrap. When a modal is spawned it is putting the overlay outside of the qunit-fixture, so when the next test is run the overlay is not removed. Anyone run into this problem? Click event (linking to a jsfiddle requires some inline code, please look at the fiddle): $("#qunit-fixture").on('click', '#click', function () { $('#error').modal('show'); }); Example: http://jsfiddle.net/Gbyza/4/ Notice how the screen

jQuery Plugin: How do I test the configuration of my plugin with qunit?

断了今生、忘了曾经 提交于 2019-12-07 16:32:57
问题 I am trying out qunit while writing a jQuery plugin and I was wondering how I can test the following: (function($){ $.fn.myPlugin = function(options){ var defaults = { foo: function(){ return 'bar'; } }; options = $.extend(defaults, options); return this.each(function(){ ... }); }; })(jQuery); This is a simple version of my qunit test: module('MyPlugin: Configuration'); test('Can overwrite foo', function(){ var mockFoo = function(){ return 'no bar'; }; //equals(notsure.myPlugin({ foo: mockFoo

'equal' is not defined : Ember-qunit does not seem to be importing

做~自己de王妃 提交于 2019-12-07 05:36:15
问题 It appears the Qunit test methods aren't available even though I'm pretty sure I am importing them correctly. I get the following errors: unit/models/friend-test.js: line 11, col 3, 'ok' is not defined. unit/models/friend-test.js: line 17, col 3, 'equal' is not defined. unit/models/friend-test.js: line 23, col 3, 'equal' is not defined. unit/models/friend-test.js: line 31, col 3, 'equal' is not defined. unit/models/friend-test.js: line 32, col 3, 'equal' is not defined. I have this test file

Checking if image properly loaded with Qunit

社会主义新天地 提交于 2019-12-07 02:44:27
问题 I'm trying to validate image URLs with Qunit by setting the URL as the src attribute of a test image and checking with the error event handler whether that went well. So far what I have is: test('image',function() { var test_image = $('#test-image'); test_image.error(function(e) { // properly triggered console.log(e); is_valid = false; // ok(false,'Issue loading image'); breaks qunit }); var is_valid = true; test_image.attr('src','doesntexist'); console.log('checking is_valid'); // occurs