describe("POST /post methods", () => {
it("should get /post ", (done) => {
const testing = {
name: "charanjit",
content: "im posting",
giph: ""
};
chai.request(server)
.post("/posts")
.send(testing)
.expect({
id: 4,
...testing
}, done)
服务器.js
server.post("/posts", (req, res) => {
const incomingRequest = req.body;
if (isValidPost(incomingRequest)) {
const post = {
name: incomingRequest.name.toString(),
content: incomingRequest.content.toString(),
giph: incomingRequest.gif.toString(),
date: new Date(),
likes: 0,
dislikes: 0,
laughs: 0,
comments: [],
//id : database.length
};
当我运行测试时,我得到TypeError: chai.request(...).post(...).send(...).expect is not a function。
我尝试按照在线教程进行操作,但测试发布请求时不断收到错误,有人可以告诉我哪里错了吗?
largeQ
相关分类