【问题标题】:testing with chai-http test didn't run使用 chai-http 测试的测试没有运行
【发布时间】:2020-04-05 19:07:32
【问题描述】:

我尝试使用 chai-http 测试我的路由文件,但它归档是因为:“TypeError: Suite argument “title” must be a string. Received type “number”

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

路线:

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

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

【问题讨论】:

    标签: javascript mocha.js chai chai-http


    【解决方案1】:

    终于解决了。问题出在 describe 函数的套件参数中

    之前:

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

    之后

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

    【讨论】:

      猜你喜欢
      • 2018-03-27
      • 2019-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-01
      • 2019-06-28
      • 2018-03-06
      相关资源
      最近更新 更多