您可以连接多个茉莉匹配器吗?
我是一个初学者的网络开发人员,他正在制作我的第一个个人茉莉花套件来测试我的学校项目之一。当我为JS函数创建规格时,我遇到了一个问题,我写了一个在1到20之间生成随机数的时间。当我尝试将多个匹配器链接在一起时,发生了错误,
it("Should return an integer value between 1 and 20.", function(){
var rollResult=rollD20();
expect(rollResult).toBeGreaterThanOrEqual(1).toBeLessThanOrEqual(20);
});
我错过了简单的东西吗?有没有一种方法可以在一个语句中应用多个匹配器,或者是将其分为多个行的正确方法:
it("Should return an integer value between 1 and 20.", function(){
var rollResult=rollD20();
//CHECK WITH SEAN. CAN YOU CHAIN?
expect(rollResult).toBeGreaterThanOrEqual(1);
expect(rollResult).toBeLessThanOrEqual(20);
});
感谢任何帮助!我很难在文档中找到一个明确的答案。
I'm a beginner web developer who is making my first personal Jasmine suite for testing one of my school projects. I ran into an issue when creating specs for a JS function I wrote that generates a random number between 1 and 20. An error occurred when I tried to chain multiple matchers together like this
it("Should return an integer value between 1 and 20.", function(){
var rollResult=rollD20();
expect(rollResult).toBeGreaterThanOrEqual(1).toBeLessThanOrEqual(20);
});
Am I missing something simple? Is there a way to apply multiple matchers in one statement or is the proper approach to split it up into multiple lines like this:
it("Should return an integer value between 1 and 20.", function(){
var rollResult=rollD20();
//CHECK WITH SEAN. CAN YOU CHAIN?
expect(rollResult).toBeGreaterThanOrEqual(1);
expect(rollResult).toBeLessThanOrEqual(20);
});
I appreciate any help! I was struggled finding a clear answer in the documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,我认为您不能连锁。但是,您可以更改
内部期望
的内部内容。我从
Unfortunately, I don't think you can chain. You can change what's inside of the
expect
though.I got this inspiration from this answer.