Supertest: connect ECONNREFUSED 127.0.0.1:80 only on one test

Created on 27 Jun 2020  路  1Comment  路  Source: visionmedia/supertest

I read #484 and my case is a bit different

I have 12 passing tests, but the one below keeps throwing connect ECONNREFUSED 127.0.0.1:80

It's the only one that uses del so maybe that's the problem?

describe('deleteOne', () => {
  it('should delete task', async done => {
    const { token } = await createUser() // this works
    const { _id } = await createTask(token) // this works
    const res = await request(app)
      .del(`api/tasks/${_id}`)
      .set('authorization', 'Bearer ' + token)
    expect(res.statusCode).toEqual(204)
    done()
  })
})

Most helpful comment

The reason can be incorrect route path.

For example:

Incorrect

request(server)
        .post("api/user")

Correct

request(server)
        .post("/api/user")

When I change the route, the error disappeared

>All comments

The reason can be incorrect route path.

For example:

Incorrect

request(server)
        .post("api/user")

Correct

request(server)
        .post("/api/user")

When I change the route, the error disappeared

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Shingaz picture Shingaz  路  5Comments

jonathanong picture jonathanong  路  4Comments

DeaconDesperado picture DeaconDesperado  路  6Comments

nitrocode picture nitrocode  路  4Comments

hacker0limbo picture hacker0limbo  路  3Comments