views:

86

answers:

3

I've been using the YUI Test framework to do TDD with JavaScript but the default TestLogger shows all sorts of messages, not just the FAIL ones. This makes scanning the log for failures an exercise in tedium, or you have to play whack-a-mole on the filter checkboxes. Is there any way to make the toggle switches on the logger window stay the same between page refreshes? Or have the Logger only show the tests that have failed?

You can see in this example that the PASS and INFO dominate when you have several tests and it is too easy to miss the FAIL messages.

YUI Test Logger screenshot

I've looked at the API for the TestLogger, which hints at there being some options. Sadly the options are not described at all. I only use YUI for this feature so I'm not an expert in the API, so can anyone lend me a hand?

A: 

Looks to me that the TestLogger class (see source) extends the Logger class. The options, therefore, ought to be those that apply to the Logger class. I think what you want is to set the categories option to only show fail messages.

var logger = new YAHOO.tool.TestLogger( element, { categories: ['fail'] } );
tvanfosson
Looked good, but sadly that doesn't seem to make any difference.
rq
+1  A: 

To filter a category in YUI 2.7 and prior, Logger must have received a message from that category before the request to hide. That means you can do

YAHOO.log('','pass','TestRunner');
var logger = new YAHOO.widget.LogReader(el,conf);
logger.hideCategory('pass');

FWIW, pre-filtering is available in YUI 3 with Console + ConsoleFilters plugin.

I would recommend you add a feature request on yuilibrary.com at http://yuilibrary.com/projects/yui2/newticket

Luke
That does the trick. And I opened a ticket as well http://yuilibrary.com/projects/yui2/ticket/2528253
rq
+1  A: 

My solution for YUI3 http://gist.github.com/309910

Daniel Steigerwald