0

i´m trying to check several requirements on a html body, received by the node-module request with jasmine-node.

The normal case would be to write something like this:

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

   }); 

});

What i would like to have is to call the website directly after the describe line and than pass body to the specific tests.

UPDDATE: To clarify: My intention is to only call the url once for my tests, not twice.

could someone can give me a hint how to do this?

Thanks and kind regards

solick
  • 2,325
  • 3
  • 17
  • 29

1 Answers1

0

You already had the right place in your example, just missing the code!

request("url...", function(error, response, body) {
  //check here the body for the first requirement
  expect(body).toContain('something');
  done();
});
Terry
  • 14,099
  • 9
  • 56
  • 84
  • Sorry you missunderstood me. I know how to check this. My question is how to pass the body var to both of the it() functions to not call the url twice for the test. – solick Jun 25 '14 at 15:13