【发布时间】:2021-03-25 11:48:22
【问题描述】:
我的快递应用中有以下中间件功能,
const { getEmployerId } = require("./employerApi");
const setEmployerDetails = (employerId) => {
return (req, res, next) => {
getEmployerId(req, res, next, employerId);
}
}
module.exports = setEmployerDetails
我想对这个中间件进行单元测试,但我不确定如何,该函数基本上返回 API 返回的任何内容,API 已经过单元测试。我将如何使用 chai 之类的东西对这个函数进行单元测试?
到目前为止,
describe('setEmployerDetails`, () => {
it('should be a function', () => expect(setEmployerDetails).to.be.a('function'));
it('should take 1 argument', () => expect(setEmployerDetails.length).to.equal(1));
});`
【问题讨论】:
标签: javascript node.js express unit-testing chai