Node.js 茉莉花节传递结果
我试图检查由jasmine节点的节点模块请求接收的html正文的几个要求 通常情况下,我们会这样写:Node.js 茉莉花节传递结果,node.js,jasmine-node,Node.js,Jasmine Node,我试图检查由jasmine节点的节点模块请求接收的html正文的几个要求 通常情况下,我们会这样写: describe("check website body", function() { it("should contain 1st requirement", function(done) { request("url...", function(error, response, body) { //check here the body for the
describe("check website body", function() {
it("should contain 1st requirement", function(done) {
request("url...", function(error, response, body) {
//check here the body for the first requirement
done();
});
});
it("should contain 2nd requirement", function(done) {
request("url...", function(error, response, body) {
//check here the body for the 2nd requirement
});
done();
});
});
我想要的是在描述行之后直接给网站打电话,然后通过具体的测试
UPDDATE:澄清一下:我的意图是只为我的测试调用url一次,而不是两次
有人能告诉我怎么做吗
感谢并致以亲切的问候您已经在示例中找到了正确的位置,只是缺少了代码
request("url...", function(error, response, body) {
//check here the body for the first requirement
expect(body).toContain('something');
done();
});
对不起,你误解了我的意思。我知道怎么检查这个。我的问题是如何将body变量传递给这两个it函数,以避免在测试中两次调用url。