0

我正在尝试检查 html 正文的几个要求,这些要求由带有 jasmine-node 的节点模块请求接收。

正常情况是这样写:

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();

   }); 

});

我想要的是在描述行之后直接调用网站,然后将正文传递给特定的测试。

更新:澄清:我的意图是只为我的测试调用一次 url,而不是两次。

有人可以给我一个提示如何做到这一点吗?

谢谢和亲切的问候

4

1 回答 1

0

您已经在示例中找到了正确的位置,只是缺少代码!

request("url...", function(error, response, body) {
  //check here the body for the first requirement
  expect(body).toContain('something');
  done();
});
于 2014-06-25T15:11:08.220 回答