Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential issue with Jest with moduleNameMapper #4524

Closed
awei01 opened this issue Sep 22, 2017 · 9 comments · Fixed by #6407
Closed

Potential issue with Jest with moduleNameMapper #4524

awei01 opened this issue Sep 22, 2017 · 9 comments · Fixed by #6407
Labels

Comments

@awei01
Copy link

awei01 commented Sep 22, 2017

Do you want to request a feature or report a bug?

bug

What is the current behavior?

  • Configure moduleNameMapper to map a certain character as an alias (in my case I used @)
  • Run jest with --watch flag,
  • Accidentally import the wrong file by forgetting the / in @/myModule, i.e. @myModule
  • Jest in client will hang at Determining test suites to run... until you kill the process.

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

What is the expected behavior?

  • Expected a Cannot find module error message

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

  • All configs and versions are in repo above.
  • Running on Mac OSx version 10.11.6
@awei01
Copy link
Author

awei01 commented Sep 22, 2017

Obviously, this is user error, but the accidental omission of '/' caused a serious headache. If this isn't a bug, at least this issue could be referred to help anyone else in similar situation.

@suzuki11109
Copy link

I got this issue too in version 21. But in version 20, the error was displayed as expected.

@AriaMinaei
Copy link

Not sure if related, but I get Determining test suites to run..., and the the whole thing stalls. If I try --watchAll, everything works with no errors, but then hitting o and going to normal watch mode gives the same message again and hangs. Only happens in version 21. Downgrading to 20.0.4 fixes the problem.

@benweissmann
Copy link
Contributor

I also just ran into this error after upgrading to Jest 21. It was similarly an issue where one of my moduleNameMappers pointed to a non-existant file.

@skevy
Copy link
Contributor

skevy commented Nov 11, 2017

I can confirm this is happening to me as well, but from what I can tell, my moduleNameMapper isn't pointing to a non-existent file. I don't get any errors when I run Jest watchAll.

@mdelgadov
Copy link

I have the same problem but it's a bit more than an inconvenience...
I do have an angular project and use the path typescript feature to define paths as @shared or @books instead of the path.
So all my paths are @something and not @/something... will have to change all of them, I think...

@Mohamed3on
Copy link

same issue here, my setup:

 "moduleNameMapper": {
      "@app/(.*)": "<rootDir>/src/$1"
    }

This works fine when I run jest or jest --watchAll but hangs on Determining test suites to run... forever when I run jest --watch.

@JasonGore
Copy link

I'm seeing the same behavior as @Mohamed3on mentioned. I am using Jest 23.1.0.

What's odd is that if you kill and rerun the command it'll eventually start working immediately.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants