qunit

Does the jQuery Paradigm go against Unit Testing or complement it?

Yes, I am aware of QUnit, but with the jQuery Paradigm all about getting things done faster with less code, and is this some how opposed to a TDD Paradigm? Or does it complement it somehow? ...

How to compare the output of serializeArray using qunit

I am using qunit and jquery. Latest version of both. In my code when I submit the form I have the event as e. I call e.serializeArray() Here is my test. equals(args.data, [ { "name": "user_name", "value": "john" } ], 'input data'); And this is the error message from qunit. expected: [ { "name": "user_name", "value": "david" } ] ...

load qUnit asyncronously

I am trying to load QUnit in js but the addevent function in QUnit.js is never fired, and it's just not working: var appendQUnit = document.createElement('script'); appendQUnit.src = 'js/utility/qunit/qunit.js'; appendQUnit.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(appendQUnit); ...

Overriding check box in JavaScript with jQuery

Help with unit testing checkbox behavior. I have this page: <!DOCTYPE html> <html> <head> <title></title> <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script> <script type="text/javascript"> $(function() { $('<div><input type="checkbox" name="makeHidden" id="makeHidden" checked="checke...

A standard event messaging system with AJAX?

Is there any standards or messaging framework for AJAX? Right now I have a single page that loads content using Ajax. Because I had a complex form for data entry as part of my content, I need to validate certain events that can occur in my form. So after some adjustments driven by my tests: asyncShould("search customer list click", 3, ...

Display JsMockito errors in QUnit

I'm currently using JsMockito and QUnit for my javascript unit testing. If JsMockito doesn't successfully verify the QUnit message is simply "Died on test #1: undefined" I then have to use Firebug to see what verification failed. I've written my own helper function to display the verification that failed, but is there a way to get thi...

QUnit and urlencode

I'm trying to test a utility method I have that creates urlencoded query strings. It somehow decodes "expected" in to: ?foo=foo val&bar=bar&val ... so it's decoding the urlencoding! test("test make_params properly url encodes", function() { var o = {"foo":'foo val',"bar":'bar&val'}; var actual = make_params(o); equals('?foo...

qUnit -- basic question

We have JS API does many things based on the HTML (markup semantics and CSS). We have many codes like this one below: function initHelpText() { $(".helpText, .tooltip, #pageHelp").css("cursor", "hand"); } Don't worry about what the code does, just an example. Now how I do use qUnit to test, this functionality works. My guess is th...

Can WatiN open a html/js doc that is compiled into an Nunit test assembly?

MVC 2 app with a Web project (including external JS files used by Views) and a Tests project (including a Nunit test to launch QUnit tests with WatiN). Everything runs fine if I include the QUnit test html and JS in the Web project and use Cassini to launch it. However, I want to avoid having any QUnit test code in the Web project, so ...

How can I trigger a native Javascript event from a QUnit test?

I'm working on a Javascript library that does not depend on jQuery, though I have jQuery and QUnit available in my tests. In the library, I attach an event to an element the way jQuery does: if (document.addEventListener) { tab.addEventListener('click', MyModule.show, false); } else if (document.attachEvent) { tab.attachEvent('click...

In javascript, how can you assert that two items are equal?

I am running Rhino and trying to determine how to do an assert_equals() or its equivalent in Javascript. From the Rhino shell I can load qunit, but I can't create an assertion that will fail. What is the easiest way to use assertions in Javascript? I will be using Javascript in environments other than a web browser, so knowing how to d...

Mock/Fake ASP.NET Service References and QUnit testing

I'm just getting into QUnit testing, and have run into a problem on my first page :S We use ASP.NET Service References to take advantage of async data loading on html pages, creating a reference to a web service in the same project. What ASP.NET does behind the scenes (ScriptManager control) is create a JS file representing the service...

How can we execute Unit Tests against DOM manipulation?

The introduction to QUnit over at netTuts.com spawns an interesting exchange (never resolved) over how to apply unit tests against actions that manipulate the DOM. The following quote (Alex York) gets to the crux: What would be nice is that if you had a function like this: function add(a, b) { var result = a + b; $(“input#...