Javascript 在Jasmine 1.3中添加自定义匹配器-显示未定义
我在jasmine 1.3中使用量角器,尝试使用示例将自定义匹配器添加到我的规范中 请注意,我没有改变他们的例子。 之后,我尝试在“it”中使用它,如下所示:Javascript 在Jasmine 1.3中添加自定义匹配器-显示未定义,javascript,testing,jasmine,protractor,end-to-end,Javascript,Testing,Jasmine,Protractor,End To End,我在jasmine 1.3中使用量角器,尝试使用示例将自定义匹配器添加到我的规范中 请注意,我没有改变他们的例子。 之后,我尝试在“it”中使用它,如下所示: expect({ "hyuk": "j" }).toBeGoofy(); 我得到一个错误: TypeError: undefined is not a function 在使用匹配器的线路上。。 有什么帮助吗?问题显然是匹配器的定义。 而不是: if (pass) { this.message = "Expected " +
expect({ "hyuk": "j" }).toBeGoofy();
我得到一个错误:
TypeError: undefined is not a function
在使用匹配器的线路上。。
有什么帮助吗?问题显然是匹配器的定义。 而不是:
if (pass) {
this.message = "Expected " + this.actual + " not to be quite so goofy";
} else {
this.message = "Expected " + this.actual + " to be goofy, but it was not very goofy";
}
此消息应该是一个由2条消息组成的数组,第一条用于pass,第二条用于not.matcher,因此如下所示:
this.message = function() {
return [
"Expected " + this.actual.hyuk + " to be gawrsh",
"Expected " + this.actual.hyuk + " not to be gawrsh"
];
};
您将
beforeach()
块放置在何处?谢谢。@alecxe在几个地方尝试过,在第一个“it”之前,在第一个“descripe”之前,规范的结构非常简单:3“it”在一个descripe中。此外,日志功能也可以正常工作和打印…您确定使用的是jasmine v1.3吗?如果使用较新版本的jasmine,通常会出现此错误。最新版本是v2.3。
this.message = function() {
return [
"Expected " + this.actual.hyuk + " to be gawrsh",
"Expected " + this.actual.hyuk + " not to be gawrsh"
];
};