supertest测试,expect不同的状态码,但都能通过

问题

it("should return 401 if token has wrong tenant", async ()=>{ request(app).get('/abc').set("Authorization", token).expect(401) })
然而当我把expect 换成其他任何非401的数字,测试均能通过。

解决方法

去掉大括号
it("should return 401 if token has wrong tenant", async ()=> request(app).get('/abc').set("Authorization", token).expect(401) )

posted @ 2021-11-24 16:00  略略略——  阅读(56)  评论(0编辑  收藏  举报