Nest: [BUG] Cannot find module 'socket.io-client/package' from 'index.js' when testing with JEST

Created on 19 May 2017  路  4Comments  路  Source: nestjs/nest

Hi guys.
I've found a bizarre bug (or maybe not :D )

I you are testing a component with JEST using @nest/testing helper and use HttpException from '@nestjs/core' JEST tests fail when the component is created with the error above.

So, steps to reproduce:

  1. create nest component
  2. add a method that throws HttpException
  3. set up JEST testing env
  4. create test module with createTestingModule method
  5. run JEST

This will make JEST fail and now even go to the test suites.

Most helpful comment

@jakub-gawlas Thanks. That was it. Works like a charm

All 4 comments

hi @Martodox 馃槃
I had the same error while using Jest (https://github.com/kamilmysliwiec/nest/issues/35), solution was add json to moduleFileExtensions in Jest config, maybe will work for you too.

Cheers 馃

I'll try on Monday.
@kamilmysliwiec Any ideas on official testing guide?

@jakub-gawlas Thanks. That was it. Works like a charm

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cojack picture cojack  路  3Comments

yanshuf0 picture yanshuf0  路  3Comments

anyx picture anyx  路  3Comments

JulianBiermann picture JulianBiermann  路  3Comments

marshall007 picture marshall007  路  3Comments