为了账号安全,请及时绑定邮箱和手机立即绑定

在 Jest 测试中 Express App 中的测试完成后无法登录

在 Jest 测试中 Express App 中的测试完成后无法登录

哈士奇WWW 2022-05-26 11:25:28
这是我的笑话测试it('test the endpoint', async done => {        const request = supertest('http://localhost:3000/myexp');        request.get('/router1')        .expect(200)        .end((err, res) => {            if(err) {                throw err;            } else {                expect(res.text).toEqual('direct use 1st');            }        });        done();    })测试成功运行,但它说测试完成后无法登录。由于我将 HTTP 请求发送到 Express App 路由器,它应该记录一些消息,例如“API 获取 [object Object] 的请求”。在这种情况下如何记录消息?
查看完整描述

1 回答

?
POPMUISE

TA贡献1765条经验 获得超5个赞

试试这个和 JSON.stringify(obj) 来查看你的对象


 it('test the endpoint', async done => {

    const request = supertest('http://localhost:3000/myexp');

    request.get('/router1')

    .expect(200)

    .end((err, res) => {

        if(err) {

            throw err;

        } else {

            expect(res.text).toEqual('direct use 1st');

            done();

        }

    });

})


查看完整回答
反对 回复 2022-05-26
  • 1 回答
  • 0 关注
  • 97 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号