supertest icon indicating copy to clipboard operation
supertest copied to clipboard

Test failing when checking response body for array

Open ollyrowe opened this issue 5 years ago • 3 comments

I found a potential issue within v1.6.4 when checking that a response body resolves to an array.

I have the following jest test which is failing:

it(`GET todos`, async () => {
  return request(app.getHttpServer())
    .get('/todos')
    .set('Authorization', `Bearer ${accessToken}`)
    .expect(200)
    .expect(await todoService.findAll());
});

Note that await todoService.findAll() returns an array.

This test produces the following error:

expected one of "[object Object]", got 200 "OK"

Reverting the supertest package version back to v1.6.3 fixes the issue and the test passes as expected.

ollyrowe avatar Aug 11 '21 16:08 ollyrowe

Potentially related change: https://github.com/visionmedia/supertest/commit/ab252f372c13128bcd1d8562d8ea395ef46d02c1

ollyrowe avatar Aug 11 '21 16:08 ollyrowe

see https://github.com/visionmedia/supertest/pull/728#issuecomment-896998201

niftylettuce avatar Aug 11 '21 17:08 niftylettuce

Thanks @niftylettuce I can confirm that this is now fixed within v1.6.5

ollyrowe avatar Aug 11 '21 17:08 ollyrowe