Hello World

要使用 Jasmine 建立最基本的測試,請轉到 spec(tests)資料夾並新增名為 testSpec.js 的檔案。

在該檔案中新增以下內容:

var request = require("request");

describe("Hello World Test", function() {
  // This is your test bundle

  describe("GET SO", function() {
    //This is testing that http GET works

    it("Checks if SO is online", function() {
      // This is description of your test - this is what you get when it fails
      
      request.get("http://stackoverflow.com/", function(error, response, body) {
        // this is your test body

        expect(response.statusCode).toBe(200);
        // this is your test assertion - it expects status code to be '200'
      });
    });
  });
});