Testing authenticated routes with JWT fails using Mocha + supertest + passport

前端 未结 1 1173
忘掉有多难
忘掉有多难 2021-01-20 18:54

I\'m trying to test authenticated routes in Mocha but the user created in before or beforeEach hooks does not persist.

In test.js

相关标签:
1条回答
  • 2021-01-20 19:51

    You need to use Authorization header with the Bearer authentication scheme:

    .set('Authorization', 'Bearer ' + jwtToken)
    
    0 讨论(0)
提交回复
热议问题