2016-05-02 199 views
0

我已經開始爲我的REST API編寫測試用例。以下是代碼。我沒有獲得個別測試用例的狀態(通過/失敗,測試用例名稱等)。我知道有一些很瑣碎,我很想念摩卡測試執行|個別測試用例無狀態

代碼:

**var supertest = require("supertest"); 
var should = require("should"); 
// This agent refers to PORT where program is runninng. 
var server = supertest.agent("http://localhost:1337"); 
// UNIT test begin 
describe("SAMPLE unit test",function(){ 
    // #1 should return home page 
    it("should return login details",function(done){ 
    // calling Login api 
    server 
    .post('/login') 
    .send({ loginid: "8787878787", password : "temp"}) 
    .expect("Content-type",/json/) 
    .expect(200) 
    .end(function(err,res){ 
     res.status.should.equal(200); 
     res.body.notFound.should.equal(false); 
     res.body.data.customerId.should.equal(20); 
     done(); 
    }); 
    }); 
    it("should return no active user",function(done){ 
    // calling home page api 
    server 
    .post('/login') 
    .send({ loginid: "8787878787", password : "temp1"}) 
    .expect("Content-type",/json/) 
    .end(function(err,res){ 
     res.body.notFound.should.equal(true); 
     done(); 
    }); 
    }); 
});** 

在命令提示符這是輸出。它沒有顯示單獨的測試用例狀態(名稱 - 在「它」塊中所描述的內容,每個測試用例已經花費了多少時間等)

。 2合格(7s)

讓我知道如何顯示個別測試用例狀態。

+0

謝謝!這已解決。 – Swapna

回答

1

摩卡在運行時有幾個顯示測試的選項。我認爲,對於您的情況,您可能需要使用List。有更多選項here

因此,在終端,你會調用你的測試與 - mocha -R list tests/test.js

你也可以使用一個全局配置的摩卡從每次寫報告類型有你,絕對,如果你有一個以上的測試文件。