1 Jun 2012 sjanes71   » (Journeyer)

Testing Wisdom

I’ve run into a problem where the DOM of Chrome and Firefox return different HTML results where they rearrange the attributes of elements when jQuery.html stringifys them. Don’t fight it outright with writing a bunch of code to check the existence of attribute values, etc.

Just write a “satisfies” assertion and get on with your day:

chai.expect(html).to.satisfy(
function(x) {
return (x === '<div a="1" b="2"></div>' 
     || x === '<div b="2" a="1"></div>'
   )
})

If the other browsers you’re testing in also give you grief, it is still probably easier (and faster) to just add to the satisfy’s clause than try to do a more sophisticated match.


Syndicated 2012-06-01 19:38:19 from sj4̄nz

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!