2016-09-13 36 views
0

在我的javascript文件中提到的代码存在。但是,当我运行通过Qunit.js和Blanket.js 我得到这个错误在Chrome的JavaScript测试用例:“无法读取的未定义的属性‘子’ - {}”无法读取Qunit测试用例中未定义问题的属性'substring'

if ($("label[for=ReservationInformation]").text().substring(0, 1) != "*") { 
      $("label[for=ReservationInformation]").text("*" + $("label[for=ReservationInformation]").text()); 
     } 

我已经定义的测试情况下, :

test("validationChecker test", 1, function() { 
    var div = $('<div>').appendTo("body"); 
    $('<input>', { id: "ReservationInformation" }).appendTo(div); 
    $('<label>', { "for": "ReservationInformation" }).appendTo(div); 
    var result = validationChecker(null); 
    equal(undefined, result, "passed"); 
    $("div").remove(); 
}); 
+1

'SUBSTR()MA男人' – madalinivascu

+0

是$ (“label [for = ReservationInformation]”)。text()在控制台中返回任何东西? –

回答

0

我认为,问题出在你的测试情况下,你没有设置你的标签文本,试图通过这种不断变化的标签制作:

$('<label>', { "for": "ReservationInformation", "text": "Hello" }).appendTo(div); 
相关问题