Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
¿Por qué mi prueba recibe el estado 200 aunque no se proporciona el token?

Definí let token e inicié sesión antes de cada implementación, pero en este simplemente token = '' para asegurarme de que el cliente no haya iniciado sesión. Se supone que debo obtener el estado 401 pero en su lugar obtengo 200. ¿Puede decirme qué estoy haciendo mal?

 describe('PUT /:id', () => { let token; let genre; let newName; let id; const exec = async () => { return await request(server) .put('/api/genres/' + id) .set('x-auth-token', token) .send({ name: newName }); } beforeEach(async () => { genre = new Genre({ name: 'genre1' }); await genre.save(); token = new User().generateAuthToken(); id = genre._id; newName = 'updatedName'; }); it('should return 401 if client is not logged in', async () => { token = ''; const res = await exec(); expect(res.status).toBe(401); });
 ● /api/genres › PUT /:id › should return 401 if client is not logged in expect(received).toBe(expected) // Object.is equality Expected: 401 Received: 200 142 | const res = await exec(); 143 | > 144 | expect(res.status).toBe(401); | ^ 145 | }); 146 | 147 | it('should return 400 if genre is less than 5 characters', async () => { at Object.toBe (tests/integration/genres.test.js:144:32)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Es posible que deba mostrarnos su carpeta de ruta que contiene el punto final para verificar si un usuario ha iniciado sesión, y también intentar verificar si su función de middleware de autenticación es necesaria en su punto final.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!