question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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:

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
kamilmysliwieccommented, Apr 28, 2018

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

1reaction
kamilmysliwieccommented, Apr 25, 2018

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

Thanks for reporting, I’ll verify.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest: Cannot read property of undefined when importing from ...
When imported to a new, empty React typescript app works perfectly. Problems start in Jest tests suites. The commonJS package version cause Jest...
Read more >
Common errors - FAQ - A progressive Node.js framework
A common case would be a module file declaring a token and importing a provider, and the provider import the token constant from...
Read more >
cannot read properties of null (reading 'usecontext') jest
Using Jest to test a react application using Axios. Getting TypeError: Cannot read properties of undefined (reading 'then').
Read more >
Continuous integration for React applications using Jest and ...
Because you are testing the App component independently of redux , anything that is provided by redux (for example, the component's props ), ......
Read more >
jest-environment-jsdom | Yarn - Package Manager
Jest will set process.env.NODE_ENV to 'test' if it's not set to something else. You can use that in your configuration to conditionally setup...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found