New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created the 'html' addon for QUnit: htmlEqual
& notHtmlEqual
assertions
#368
Created the 'html' addon for QUnit: htmlEqual
& notHtmlEqual
assertions
#368
Conversation
In jQuery UI we have something similar, called Usage is optimized for comparing before/after html, though I can us using the htmlEqual assertion underneath. Though that may require exposing the actual html comparsion as a separate method, so that we can keep It doesn't look like you're doing anything specific for checking styles. That's important for jQuery UI: jquery/jquery-ui@050e71b What do you think? If there's not enough overlap or potential for reuse, we can just land this as-is. |
Yeah, good call on I definitely see plenty of overlap in the data collection and normalization parts of the That said, I will likely update this PR with lots of stolen de-jQuery-ed code from it. Am I mistaken or does the |
It's likely that there are a bunch of things we missed. Would be great to improve that. |
Understood. I'll do some consolidation and update the PR (or send a new one) in the next few days. |
oh nice, was just contemplating tackling just this kind of thing. +1 |
So, in redoing this addon, I've reached the point where — in order to correctly get the calculated
The latter is preferable because I can rely on having a clean slate for CSS but it also adds the factor of asynchronicity to it such that I cannot rely on it being loaded for the first Suggestions on the best way to handle this? P.S. I can share my code but it's not in an all-green (passing) state due to the |
Seems like maybe I can avoid the asynchronous issue if I just I'll give it a try soon. |
This Assuming the above is right, wouldn't (if not already) detaching be sufficient? No need for an iframe, just detach and re-insert (or clone). |
Do the It also deals with normalizing shorthand properties, dealing with overrides (e.g. style="color:red; color:green;"), etc. Do either the P.S. The synchronous |
I was indeed thinking about using Not entirely a surprise, the W3 spec has been changed to support this (webkit#14563). In Firefox |
fixing up the style attribute, per @bassistance's suggestion. Also updated to utilize QUnit's existing `deepEqual` functionality with a serialized form of nodes (similar to jQuery UI's tests) rather than doing escalated string comparisons.
Monster update pushed! Please check it out [again] and let me know what you think. :) Good News
Bad News
I'll look into those failures within the next few days... but for now, it's 3:30am! 😴 |
if ( !s ) { | ||
return ""; | ||
} | ||
return window.jQuery ? window.jQuery.trim( s ) : ( s.trim ? s.trim() : s.replace( /^\s+|\s+$/g, "" ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should either inline the jQuery implementation or use the simple one you have right now. Feature-checks for jQuery shouldn't be in QUnit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
Guys: Please hold off on reviewing for the moment. I'm cleaning up this "late night coding" cruft and changing how attributes are serialized as the currently pushed code doesn't work in IE7. I looked at the tests that are failing in IE8, all are unfortunately related to IE8- not normalizing named/hex/RGB color values like IE9+ and all the other browsers do (a difference in using I assume QUnit's support goal is IE7+ but I don't see that stated anywhere. Can someone confirm? |
…s to the minimum (255 -> 103) by keeping track of my own results rather than relying on assertions. Still have tests failing in IE7-8, will work on those soon.
@jzaefferer @Krinkle Can either of you confirm the browser support goals of QUnit with regard to IE: IE6+, IE7+, IE8+, IE9+? I would also love to see the support goal clearly stated somewhere in the QUnit documentation and/or on the website. |
Afaik QUnit's browser support goal is the same as the traditional matrix for jQuery core. TestSwarm and QUnit should stay on the low end of the matrix to avoid other projects from being forced to up their support merely by being unable to test their code in older browsers. So IE6 is most certainly included and required to work (at least as Grade B, meaning functionality 100%, but presentation is allowed to degrade horribly, like TestSwarm already does due to Bootstraps layout). I don't have an official statement though, created #412 for that. |
@JamesMGreene considering Timo's comments about add-ons (somewhere), I'm thinking that this should probably go in a standalone repository. That way you're free to support whatever browsers are reasonable to support. While QUnit should run in IE6 as long as jQuery is still testing against that, I don't think anyone else should. For example, jQuery UI doesn't support IE6 anymore. I haven't seen a single complaint about that... As for finding add-ons, that needs to be improved. But even "bundled" add-ons aren't having good visibility, so it doesn't matter much where the code actually lives. And there's a lot of arguments for having each add-on in its own repository. |
Well, I do think I can make this addon work for all of QUnit's supported browsers, it's just a question of if it is worth the time investment. :) So should separate repos be the new direction? Do we want the existing ones to remain under the jquery org or just under individual maintainers' accounts? |
I'm not sure yet what to do with the existing ones. But let's not add new add-ons, keep them on individual accounts instead. |
OK, I will move this to its own repo. Any recommendations for consistent naming? I'm thinking "qunit-assert-html" for this one. The theoretical XUnitLogger will probably be "qunit-reporter-xunit". |
Yep, that sounds good. I was considering creating qunit-[whatever] repos under the jquery organization for existing add-ons. Need to check with other project people though. |
I pushed this branch to a new repo: JamesMGreene/qunit-assert-html. I will reduce it to just the addon from there. |
Could you send a PR against qunitjs.com to add it to the add-ons list? |
@jzaefferer: Done. Issue: qunitjs/qunitjs.com#43 |
Created the 'html' addon for QUnit, introducing
htmlEqual
andnotHtmlEqual
assertions.This is a throwback to the
assertHTMLEquals
method from very-deprecated JsUnit, which compares two HTML strings after doing some normalization. My implementation takes it a step further by also sorting the attribute nodes before doing the final comparison since modern browsers do not predictably sort the attributes like the old browsers usually did.