我正在尝试检查html主体上的几个需求,这些需求是由使用jasmine-node的node-module请求接收到的。
通常的情况是编写类似这样的代码:
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,而不是两次。
有没有人能给我一点提示,怎么做?
感谢并致以亲切的问候
发布于 2014-06-25 23:11:08
您已经在示例中找到了正确的位置,只是遗漏了代码!
request("url...", function(error, response, body) {
//check here the body for the first requirement
expect(body).toContain('something');
done();
});https://stackoverflow.com/questions/24412352
复制相似问题