Search code examples
javascriptmocha.jschaichai-http

testing with chai-http test didn't run


i try to test my routes file with chai-http but it filed because:"TypeError: Suite argument "title" must be a string. Received type "number"

my test.js

const { assert, should, expect, sinon } = require("../baseTest");
const chai = require("chai");
chai.use(require("chai-http"));

describe.only("Test the "/" routes", () => {
  const server = "http://localhost:3000";
  it("", done => {
    chai
      .request(server)
      .get("/")
      .end((err, res) => {
        if(err) done(err);
        res.should.have.status(200);
        done();
      });
  });
});

routes:

module.exports = (express, DefaultController) => {
    const api = express.Router();

    api.get('/', DefaultController.help);
    api.get('/status', DefaultController.status);
    return api;
};

Solution

  • finally I solved it. the problam was in the suite argument of the describe function

    before:

    describe.only("Test the "/" routes", () => {});
    

    after

    describe.only("Test the / routes", () => {});