2013-03-13 57 views
1
为什么被忽略YUI测试控制台

如果我运行一个测试情况就是这样,我的测试结果显示了YUI 测试控制台窗口小部件内:当测试用于两个YUI实例

YUI({debug: true}).use('test', 'event-base', 'test-console', function (Y) { 
    fooTests = new Y.Test.Case({ 
     name: "foo", 
     testFoo: function() { 
      Y.assert(5 == 6); 
     } 
    });  

    Y.on("domready", function() { 
     (new Y.Test.Console({ 
      newestOnTop: false, 
      style: 'block' 
     })).render('#log'); 
     Y.Test.Runner.add(fooTests); 
     Y.Test.Runner.run(); 
    }); 
}); 

如果我运行完全相同的代码,但创建另一个YUI实例,首先使用'测试',测试显示在浏览器的JavaScript控制台(如果它是打开的)。

YUI({debug: true}).use('test', function (Y) { 

}); 

YUI({debug: true}).use('test', 'event-base', 'test-console', function (Y) { 
    fooTests = new Y.Test.Case({ 
     name: "foo", 
     testFoo: function() { 
      Y.assert(5 == 6); 
     } 
    });  

    Y.on("domready", function() { 
     (new Y.Test.Console({ 
      newestOnTop: false, 
      style: 'block' 
     })).render('#log'); 
     Y.Test.Runner.add(fooTests); 
     Y.Test.Runner.run(); 
    }); 
}); 

当另一个YUI实例使用'test'时,有没有办法让结果显示在测试控制台窗口小部件中?

回答

1

我找到了答案here

我不得不添加

logSource: Y.Global 

要Test.Console的参数对象。

(new Y.Test.Console({ 
     logSource: Y.Global, 
     newestOnTop: false, 
     style: 'block' 
    })).render('#log');