nest: exception in Jest tests: `TypeError: Cannot read property 'module' of undefined` when using `forwardRef` in module `imports`

I’m submitting a…


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When creating a testing module using Test#createTestingModule method and importing a Module that has a circular dependency with another module(s) implemented using forwardRef, test fails with the following exception:

TypeError: Cannot read property 'module' of undefined

See the screen and the full exception text with a call stack in this gist

However the code itself compiles and works correctly. (see the screen)

screenshot 2018-04-25 00 16 06

screenshot 2018-04-25 00 17 26

Expected behavior

Tests should work

Minimal reproduction of the problem with instructions

Here is the repo of the example project. Just run yarn test:single to reproduce.

What is the motivation / use case for changing the behavior?

Can’t test the code containing the circular dependency.

Environment


Nest version: 4.6.6
 
For Tooling issues:
- Node version: 9.4.0
- Platform:  Mac

Others:

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 15 (4 by maintainers)

Most upvoted comments

v5.0.0-beta.4 is using rxjs v.6.0.0 now

@alexandr2110pro keep in mind that Nest is not compatible with rxjs 6 yet (release took place yesterday)

Thanks for reporting, I’ll verify.