Zen Reverse Coding

I am writing a javascript unit test suite, and one of the features I would like to add is the ability to claim that a particular element and its children conform to a given HTML structure.

My first idea is to use jQuery (well, Sizzle) and ask users to write Zen Code for approval. My first question is: "Was this done before? Can I steal it?" If not, is there a specification printed anywhere to parse the Zen Code instruction? Are there any shortcuts I could make, given the power of Sizzle?

+3
source share
1 answer

I think you can get there with a hiss + http://api.jquery.com/size/

Example zen code request: "div # page> div.logo + ul # navigation> li * 5> a". Testing if the page has the same structure in jQuery will be as simple as $ ("div # page> div.logo + ul # navigation> li> a"). Size () == 5.

If your users are no longer familiar with the zen code, api tests like assertSelects (selector, number_of_returned_items) should be more comfortable.

+1
source

All Articles