[英]Mocha Test Execution | No status for individual test cases
我已經開始為我的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();
});
});
});**
在命令提示符下,這是輸出。 它沒有顯示單個測試用例的狀態(名稱-在“ it”塊中描述的內容,每個測試用例花費了多少時間,等等)
。 2次通過(7秒)
讓我知道如何顯示各個測試用例的狀態。
Mocha有一些用於在測試運行時顯示測試的選項。 我認為,就您的情況而言,您可能希望使用List
。 有更多的選擇在這里 。
因此,在終端中,您將使用mocha -R list tests/test.js
調用測試。
您還可以為mocha使用全局配置,以確保每次編寫報告程序類型時都可以使用,當然,也可以確定是否有多個測試文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.