2013-03-13 31 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');