Intro my new QUnit callback assertion plugin
This is a QUnit assert plugin to test sync callback. You can easily assert that the callback can (only) be called at the correct moment, and has the correct times. Advices from anyone are really welcome! You can download from: https://github.com/jareguo/qunit-assert-callback Usage var obj;
// Create and return a new callback wrapper for handling assertion. obj.callback = assert.callback(callbackFunction_opt);
// By default, the callback is not allowed to call unless you call its enable method
phonegap application containing SQLite database testing by qunit
hii, I am new to Qunit. I want to test PhoneGap application containig SQLite database coding by Qunit.Can anyone give me suggestion,How I can do that? //This is javascript code:- window.addEventListener('load', function(){ // Wait for PhoneGap to load document.addEventListener("deviceready", onDeviceReady, false); }, false); // PhoneGap is ready function onDeviceReady() { var db = window.openDatabase("Database2", "1.0", "DigitalNoiz", 200000);
Does QUnit support catching active timeouts?
Hello When a test starts a timeout with setTimeout but this isn't execute before the test is finished this timeout can affect the next test. Such problems are hard to debug. Does QUnit supports in some finding such problems? I implemented an ad-hoc solution but IMHO this should be part of the QUnit framework the same way as checking for namespace pollution is. Raimar
Testing using Qunit & Mockjax
I am currently learning how to use mockjax together with Qunit but have no idea how to test the following 2 functions.. the following is the code i am making use of which includes both javascript & JQuery, Could anyone help me by giving advice on how to achieve this? $(document).ready(function(){ $("button").click(function() { var htmlFrom=$("#from").val(); var htmlTo=$("#to").val(); $("#ResultTitle").hide(); $.get ("myHTML") departure:htmlFrom, destination:htmlTo }, function(data,status) { parse(data,status,htmlFrom,htmlTo);
Mock service call QUnit with QUnit
I have a javascript file where I am using include.js. The file (ContactsManager) looks something like this: define([], function() { 'use strict'; var exports = {}; exports.ContactsManager = function (service, contactsContentHolder) { this.getExistingContacts = function() { // display wait image until service call does not returns var waitImageDiv = document.createElement('div');
QUnit test runner output via Karma process?
I currently have two runners for my tests, which means maintaining two, and I'd like to meld them into one process. I have the standard QUnit html runner page, and I have Karma running tests through PhantomJS. Is it possible, from Karma, to pipe and output test results through the QUnit html runner page? What I'm ultimately after is the reporting and granularity of the QUnit runner page, but having that sourced and output via Karma, rather than having to maintain the QUnit runner page as a separate
Spy on functions within a module
I define a module in javascript as below: var test_module = (function () { var foo = function () { some_processing; } var init = function () { foo(); } return { init: init }; })(); As you can see, foo is not exported. Only init is visible from the outside world. How can I spy on foo from a qunit test, and make sure init is calling foo ? Thanks for your help!
Changing rerun url
I was wondering if there is a parameter or setting I can set that will change the URL that is fired when the "rerun" link is clicked on one of my tests. My current application is built in Require.js and and Backbone.js, so right now when I click on the rerun link, it navigates me back to my home page. I was just hoping that there is a way to modify where the rerun link points, rather than have to start managing a new set of URL paths in my router. Thanks!
Start with QUnit
Hi, I'm new in QUnit and testing JS. I am reading a lot of tutorials but i have a question. How to test DOM ? Tutorial said that i have to create new file (test_qunit.html) <pre> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>QUnit Example</title> <link rel="stylesheet" href="/resources/qunit.css"> </head> <body> <div id="qunit"></div> <div id="qunit-fixture"></div> <script src="/resources/qunit.js"></script> <script src="/resources/tests.js"></script> </body> </html> </pre> OK In
QUnit from within dijit widget startup
Hello, I'm brand-spanking new with jQuery, but it seems to be working pretty well for my needs. I'm using it with sinon.js to test all kinds of nested dijit widgets that are loaded using AMD loading. These widgets contain and manage the tests => a boolean decides when they run or not and the execution happens after the widget's startup(), i.e. all required setups are already performed ISSUE: When pages with these widgets are loaded by refreshing the entire browser page (e.g. cursor in the address
Cross-Site Scripting in qunit.js file
Hi Friends, We are facing Cross-Site scripting issue in qunit.js file. Please find the code snippet below.: if ( window.location ) { window.location.href = window.location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent(text); } I have attached the report screen snap for this issue. Please look into this and give your suggestion regarding this vulnerability. Thanks, Arun
How to start implement QUnit
Hi everyone, I am new in the QUNit world and Im not English so apologise for any future mistakes XD So my issue is: I have an HTML page where I load a MediaPlayer.swf. I'll post how my folders are organized: MediaPlayer (folder) - app (folder) -- img (folder) -- js (folder) --- main.js --- jquery.js --- backbone.js --- handlebar.js --- qunit.js -- styles (folder) - MediaPlayer.html - MediaPlayer.swf so now what Im wondering
Callback to run before all tests in a module
I have a need to run a setup/teardown callback to setup state once for all the tests within a module. I have something implemented that works like: module("My Module", { beforeAll: function(){ // will run once for each module in which it's defined before all tests }, afterAll: function(){ // will run once for each module in which it's defined after all tests have run } }); Would this be something we'd be interested in having in QUnit?
QUnit Module Setup and Teardown
For the QUnit callback functions for setup and teardown: Does setup get called before each test function? Does teardown get called after each test? From what I can see in my own tests it seems like setup gets called ONCE per module and teardown gets called once PER TEST. Just wondering if this assumption is correct or not. Thanks!
On the architecture of qunit-fixture
[Please ignore this idea and focus on the reply. It explains why we were seeing setup and teardown called out of order and why we were under the impression that qunit-fixture was designed poorly. Cheers!] (Preface: I'm a relative new-comer to QUnit. I apologize if the following aspects of qunit-fixture have been discussed ad nauseam. I searched on google, stackoverflow--and of course here--and found nothing similar.) qunit-fixture is obviously a key aspect of QUnit and it does its job of preventing pollution just
How to unit test extjs application using qunit ?
please can any one suggest me some tutorials or reference links for qunit for extjs
Stripping QUnit tests for deployment?
I have QUnit tests running in my project and it's great - except I don't want to have to manually comment them out every time I deploy my code (or have the extra bits go over the wire). Is there an easy solution for this? Perhaps this is provided as a feature of a minifier. Does anyone have a good solution for getting the benefits of Unit testing in Javascript without having to take additional steps to remove the tests from the actual customer facing code? Thanks! Nathan
test click with QUnit
i want to test this js code with Qunit but i can't find solution for the following error : Object expected Source: file :/ / / C :/ / / / video.js:..... 5 Which corresponds to line 5 of my code below 1- function clickCamSel() { 2- if (player_state == 3) 3- { .. ......... 4- } } 5- $("#t_vid_type_live").click(clickCamSel);
How to test inner functon in qunit
I just started with Qunit, and don't know much about it. The problem I'm having is that I have written this function in my code and want to test this using Qunit. <script> function calc(firstno, secnum) { return firstno + secnum; } function main(firstno, secnum) { return calc(firstno, secnum); } </script> So, how should I test the calc function when I write a test case for the main function.
Module names and test names prevent QUnit operating
Hi, I've just started working with QUnit this morning and I'm getting some unexplainable behaviour. Calling a module anything other than "QUnit Test" and a test anything other than "Sample test" will prevent the tests from running at all. This works (in Safari 4 and Firefox 3.6): var domReady = function(f) {document.addEventListener("DOMContentLoaded", f, false);}; domReady(function(){ module("QUnit Test"); test("Sample test", function() { expect(1);
QUnit inconsistency/alternately fails tests
I have a simplified QUnit test which consists of 2 simple tests that fails randomly/alternately for no good reason (They are both atomic, meaning that one test doesn't change anything of the other element) Please see this jsFiddle try to run multiple times module("Basic actionBind"); //two simple tests test("action1", function() { ok(ele2.trigger("click").hasClass("clicked"), "basic click action"); }); test("action2", function() { ok(ele1.click().hasClass("clicked"), "basic click action"); }); http://stackoverflow.com/questions/16444561/qunit-inconsistency-alternately-fails-tests
Command line/headless/continuous integration
It took me a little while to find the PhantomJS addon and add automated testing to my command line build system. I just made a blog post about eventually succeeding, and thought I would share it in case it's helpful to anyone else. I also discovered that jQuery can't trigger event handlers that were registered with .addEventListener() Thank you for QUnit and the PhantomJS addon!
Problem finding in Qunit
Hi, I m new in Qunit. Could You please help me in below. If I wanted to test Textarea's or textbox's maxlength or maxlimit then what code should i Prefer. I tried a lot but its not working. Here is my code: <html> <head> <meta charset="utf-8"> <title>QUnit Example</title> <link rel="stylesheet" href="Qunit.css"> </head> <body> <div id="qunit"></div> <input type="text" id="fname"/> <script src="Qunit.js"></script> <script src="jquery-1.7.2.js"/> <script src="tests.js"></script>
integrating JQuery Qunit with ASP.net MVC 4.0
Hi, I m new in Jquery Qunit. Could you please help me in Integrating with ASP.net MVC 4. 0 I have an application build in ASP.net. for that i want to automate Unit testing. Could you please explain me with an example. Application contains numeric and many more validation. Thanks in Advance, Gauri Rane
dropdownlist issue
$(document).ready(function () { $("#" + btnCancel).click(function () { var o ="--Select--"; // For Example $("#" + ddlEntityName + " option:contains('" + o + "')").attr('selected', 'selected'); return false; }); }); but not working in mozilla
Browser issue
$("#" + DDL + " option:contains(" + Option + ")").attr('selected', 'selected'); where DDL is id of dropdownlist and Option is Text to be selected.. it working fine in IE, But in mozilla not working
Qunit test cases for javascript logging
I am working on javascript client logging.I have function in JavaScript called WriteLog,which basically post a message/Exception to specified server URL through Ajax post and also writes a message/exception to console.log,console.error and console.warn(if available) based on type(error,warn,info passed to WriteLog function). I am looking for reference how to write qunit testing cases for WriteLog function( to check a ajax request has been made to a server and cross verify a message written to console.log)
qunit and requirejs
Just posted this on SO, wondered if I'd have more luck here: 'm using QUnit to test my JavaScript. I'm also using requirejs. I have test code which looks like this: QUnit.config.autostart = false; require(['tests/tests'], function () { QUnit.start(); //Tests loaded, run tests }); This works great in FF (19.0.2 as it happens) but in both Chrome (27) and IE (10), I'm getting a QUnit error: "pushFailure() assertion outside test context" Turns out that I don't need the call to QUnit.start in IE and Chrome.
global failure when running qunit simple test in container
i am running a real simple qunit test, the one you see from web site. it runs fine in browser. But when I deploy to a container such as jetty, and then visit the page, I am getting 1 success and another error: global failure (1, 0, 1) script error, source : 0 what may be the problem? i am using qunit 1.11 Thx! Yan <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>QUnit basic example</title> <link rel="stylesheet" href="/resources/qunit.css"> </head> <body> <div id="qunit"></div> <div
How can I pass a datauri of a qunit test to testswarm?
Hi, I'm looking for a way to run the qunit test without hosting on a webserver. I was thinking of writing a script that can convert javascript under test and the qunit test into 1 data URI and feed it to test swarm. The URL would look something like... data:text/html;base64,Cgo8aHRtbD4KPGhlYWQ+CiAgPG1ldGEgY2hhcnNldD0idXRmLTgiPgogIDx0aXRsZT5RVW5pdCBFeGFtcGxlPC90aXRsZT4KICA8IS0tIFF1bml0IHN0dWZmIC0tPgogIDxsaW5rIHJlbD0ic3R5bGVzaGVldCIgaHJlZj0iaHR0cDovL2NvZGUuanF1ZXJ5LmNvbS9xdW5pdC9xdW5pdC1naXQuY3NzIj4KICA8c2NyaXB0IHNyYz0iaHR0cDovL2NvZGUuanF1ZXJ5LmNvbS9xdW5pdC9xdW5pdC1naXQuanMiPjwvc2NyaXB0PgogIAogIDwhLS0gdGVzdCBzd2FybSBsaW5rIC0tPgogIDxzY3JpcHQgc3JjPSJodHRwOi8vbXl0ZXN0c3dhcm0uaW50ZXJuYWwuY29tL2pzL2luamVjdC5qcyI+PC9zY3JpcHQ+CgogIDwhLS0gYXBwbGljYXRpb24gc2NyaXB0cyAtLT4KPHNjcmlwdD4KeCA9IDE7Cjwvc2NyaXB0PgoKICA8IS0tIFRlc3RzIC0tPgogIDxzY3JpcHQ+CnRlc3QoICJoZWxsbyB0ZXN0IiwgZnVuY3Rpb24oKSB7CiAgb2soIHggPT0gIjEiLCAiUGFzc2VkISIgKTsKfSk7CgogIAogIDwvc2NyaXB0PgoKPC9oZWFkPgo8Ym9keT4KICA8ZGl2IGlkPSJxdW5pdCI+PC9kaXY+CiAgPGRpdiBpZD0icXVuaXQtZml4dHVyZSI+PC9kaXY+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==
Why isn't Qunit namespaced?
I'm curious why Qunit sticks all it's functions in the global namespace instead of behind a namespace, e.g. "qunit.ok", "qunit.test", etc.?
Quarantine tests
Some CI tools (eg. Atlassian Bamboo) have the ability to quarantine tests that are failing for either expected reasons (or fail intermittently). Jenkins also has an open feature request for a similar thing. http://blogs.atlassian.com/2012/04/test-quarantine-continuous-integration-bamboo4/ https://issues.jenkins-ci.org/browse/JENKINS-14089 Is this something that has (or would be) considered for QUnit? Currently if a test is failing, your options are either: Fix the code (or the test) Comment out
Is there a way to prevent a test from running if the setup will say so?
Is there a way to prevent a test from running if the setup will say so? Currently the way I implement this is I have an outside variable that I set to true or false depending on whether I want the test to run and I check this variable in the test before I begin to run the rest of it. This is not elegant but I can't find another way. The reason that I do this is during setup I need to make an async call to clean the contents of a table and if that doesn't finish on time I need to not run the test.
QUnit equal assertion very slow when reporting “complex” object
(Note: I've also posed this question on stackoverflow here:http://stackoverflow.com/questions/14464621/qunit-equal-very-slow-when-reporting-complex-object) I've found that QUnit can be very slow when generating a failure report when an equal assertion fails and the expected value is a complicated object. Is this a known issue? Is there any way to limit the depth QUnit recurses into the "expected" object while generating its failure report? In the meantime I'm thinking of switching to using ok, but
JQuery UI garbage collection
Folks, I created a ticket last night in jQuery forum but moved it to here as I think it is more related. The subject was "How to measure DOM size?" and it raises questions that would effect app writers (be it for intranet or hand held devices). My initial tests came back with some scary results, but further analysis reversed those thoughts and told me that overall, its a non-issue but I still thought I would share my results. (I discovered that some UI effects clean up better than others). For reference,
How to measure DOM size?
Hi all, I regularly keep an eye on the size of my DOM using $(*).length however it is not as accurate as I would like it to be. Is there another method I can use? I want to, in effect, count every character that exists within my HTML document (dynamically created from the client or served from the server). Why? When I use jquery ui it dynamically adds/removes to the document weight. When writing an application that requires few page reloads, I am afraid of legacy data stacking up. It is true that
Using a function in the expected field of equal()
I have a function that starts a timer. Im using the asyncTest function to test my lapTime function, to make sure its within an acceptable range. I set the asyncTest to 4000 milliseconds, and then set my equal() to expect a value of 4. When running the test, it came back with a value of 3.999 and 3,998. I decided to then just change my expected to be >=4, which would tell me if my function was grabbing the time correctly. when i changed my expected to be (lapTime() <= 4, ) it says my expected output
How to test a form submit in QUnit
I would need to test the a form submit but cannot see on how to do this in QUnit. Because a new page will be loaded it most likely involves the use of an "iframe" but I cannot really see on how to do this and any help or example would be very much appreciated. A typical use case would be a submit of a form that will be processed in the backend and returns a new page and the content of the page must be checked against the original form content. Please also note that I'm aware that this can be quite
Run two test files on one page?
Is it possible to include two javascript files of tests in a page? I want to have one file for tests that common to all pages, and one that is specific to the page. But if try <div id="qunit"></div> <script src="scripts/qunit_home/qunit/qunit.js"></script> <script src="scripts/tests/myTests.js"></script> <script src="scripts/tests/demoTest.js"></script> only the last test file runs. If I switch the order of the last two lines, the other set of tests runs.
Banner and Rerun links don't work when loading file directly
This may be just an IE issue. I haven't tried this with other browsers. Create an html file such as MyTests.htm. Run it by going to the command line and simply use: MyTests.htm<CR>. Do this instead of using something like http://localhost/MyTests.htm. IE will bring up the tests and they run fine. However, clicks on Rerun or the Banner are ignored. I debugged thus and found the bug. It appears that the code to create the URL only understands HTTP://. Not FILE://. I created a work around in our code.
Next Page