9

I am having the error ECONNREFUSED 127.0.0.1:80 when running a test e2e with Nestjs to test a dto.

Here is my code:

const TEST_URL = 'test';

@Controller(TEST_URL)
class TestController {
  @Post()
  public test(@Body() param: TimeTableParam) {
    // nothing
  }
}

describe('TimeTableParam', () => {
  let app: INestApplication;

  beforeAll(async () => {
    const module: TestingModule = await Test.createTestingModule({
      controllers: [TestController],
    }).compile();

    app = module.createNestApplication();
    await app.init();
  });

  afterAll(async () => {
    await app.close();
  });

  describe('...', () => {
    it(`should ...`, () => {
      //...
    });
  });
});
Baboo
  • 4,008
  • 3
  • 18
  • 33

1 Answers1

18

The fix was really simple but hard to find. Thanks to this thread this is what I did:

const TEST_URL = '/test';
                  ^ add a '/'
Baboo
  • 4,008
  • 3
  • 18
  • 33