addons/web/static/tests/helpers/qunit_config.js
/**
 * Add a sort button on top of the QUnit result page, so we can see which tests
 * take the most time.
 */
Add a sort button on top of the QUnit result page, so we can see which tests
take the most time.
Add a sort button on top of the QUnit result page so we can see which tests take the most time .
function _addSortButton() {
    sortButtonAppended = true;
    var $sort = $('<label> sort by time (desc)</label>').css({float: 'right'});
    $('h2#qunit-userAgent').append($sort);
    $sort.click(function() {
        var $ol = $('ol#qunit-tests');
        var $results = $ol.children('li').get();
        $results.sort(function (a, b) {
            var timeA = Number($(a).find('span.runtime').first().text().split(" ")[0]);
            var timeB = Number($(b).find('span.runtime').first().text().split(" ")[0]);
            if (timeA < timeB) {
                return 1;
            } else if (timeA > timeB) {
                return -1;
            } else {
                return 0;
            }
        });
        $.each($results, function(idx, $itm) { $ol.append($itm); });
    });
}
function _addSortButton ( ) { sortButtonAppended = true ; var $sort = $ ( '<label> sort by time (desc)</label>' ) . css ( { float : 'right' } ) ; $ ( 'h2#qunit-userAgent' ) . append ( $sort ) ; $sort . click ( function ( ) { var $ol = $ ( 'ol#qunit-tests' ) ; var $results = $ol . children ( 'li' ) . get ( ) ; $results . sort ( function ( a , b ) { var timeA = Number ( $ ( a ) . find ( 'span.runtime' ) . first ( ) . text ( ) . split ( " " ) [ 0 ] ) ; var timeB = Number ( $ ( b ) . find ( 'span.runtime' ) . first ( ) . text ( ) . split ( " " ) [ 0 ] ) ; if ( timeA < timeB ) { return 1 ; } else if ( timeA > timeB ) { return - 1 ; } else { return 0 ; } } ) ; $ . each ( $results , function ( idx , $itm ) { $ol . append ( $itm ) ; } ) ; } ) ; }
Add a sort button on top of the QUnit result page, so we can see which tests
 take the most time.
Add a sort button on top of the QUnit result page so we can see which tests take the most time .