【发布时间】:2021-02-24 16:44:17
【问题描述】:
我刚刚升级到节点 14.15.4,现在任何带有 send 的超测试 post 请求都失败并出现错误“TypeError: mime.lookup is not a function”。
it("Should be able to select an address", () => {
return request(app).post(`/admin/machines/${newmachine._id}/assignments/add`)
.send({userid: testuser._id.toString()})
.expect(302)
.then( (res) => {
expect(res.headers.location).to.include(`/admin/machines/${newmachine._id}`);
});
});
我得到错误:
Should be able to select an address:
TypeError: mime.lookup is not a function
at Test.Request.type (node_modules/supertest/node_modules/superagent/lib/node/index.js:265:38)
at Test.RequestBase.send (node_modules/supertest/node_modules/superagent/lib/request-base.js:575:21)
at Context.<anonymous> (test/routes/admin/machines.js:275:10)
at processImmediate (internal/timers.js:461:21)
如果我使用“字段”而不是发送,错误就会消失:
return request(app).post(`/admin/machines/${newmachine._id}/assignments/add`)
.field('userid',testuser._id.toString())
.expect(302)
.then( (res) => {
expect(res.headers.location).to.include(`/admin/machines/${newmachine._id}`);
});
});
我错过了什么?
【问题讨论】:
标签: node.js express mocha.js supertest