javascript - 使用 chai-http 测试的测试没有运行
问题描述
我尝试使用 chai-http 测试我的路由文件,但它归档是因为:“TypeError:套件参数“title”必须是一个字符串。收到类型“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;
};
解决方案
最后我解决了。问题出在 describe 函数的套件参数中
前:
describe.only("Test the "/" routes", () => {});
后
describe.only("Test the / routes", () => {});
推荐阅读
- .net-core - .NET Core - 使用 AddSingleton() 在容器中配置的类需要是单例吗?
- laravel - 为什么 vagrant up 不生成代码目录?
- java - 如果它取决于 Mono 对象,我如何返回响应?
- python - 向训练有素的 tensorflow keras 模型添加重新缩放层(或任何层)
- javascript - 如何使用基于字符的正则表达式将值匹配到单独的可选组中?
- python - pip 会卸载模块吗?
- excel - 我收到编译错误预期识别功能错误
- flutter - 背景图像未设置为白色 | 为文本添加样式
- excel - excel中的MOD函数
- angular-material - 在 ngIf 过滤器之后,Mat Cards 没有重新排列到同一行