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

2233322 picture 2233322  路  3Comments

artaommahe picture artaommahe  路  3Comments

rlesniak picture rlesniak  路  3Comments

thohoh picture thohoh  路  3Comments

janckerchen picture janckerchen  路  3Comments