简体   繁体   中英

Mocha Test Execution | No status for individual test cases

I have started writing test cases for my REST API's. Below is the code. I am not getting status of individual test cases (pass/fail , test case name etc). I understand there is something very trivial which I am missing

Code :

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

On command prompt this is the output. It is not showing individual test case status (name- what is described in "it" block,how much time each test case has taken etc)

. 2 passing (7s)

Let me know how to display individual test case status.

Mocha has a few options for displaying tests as they run. I think, for your case, you might want to go with List . There are more options here .

So, in the terminal, you would invoke your tests with - mocha -R list tests/test.js

You can also use a global config for mocha to have you from writing the reporter type each time and definitely if you have more than one test file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM