【发布时间】:2021-06-16 07:49:12
【问题描述】:
您好,我需要测试一个登录控制器,但总是 400,我需要模拟 200,但老实说,我不知道该怎么做,这里是我的测试:
test("JWT OK, status 200, remember false", async () => {
const code = "code";
const state = "state";
const company = "comany";
const response = await supertest(app)
.get(`/auth/${company}`)
.send({
"state": state,
"code": code
})
});
这里是我的代码控制器登录,它是从 (/auth/${company}`) 调用的
export class AuthService {
public async Login(req: Request, res: Response): Promise<Response<any> | undefined> {
try {
const company: IAuth['company'] = req.params.company;
const state : IAuth['state'] = req.query.state;
const code : IAuth['code'] = req.query.code;
....some code....
问题始终是 response.status 400,我不知道如何测试模拟状态 200...
对不起,我刚开始在这个领域..
【问题讨论】:
标签: typescript jestjs