-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
jest --watch hangs silently if moduleNameMapper cannot locate module #4883
Comments
Do you mind trying this with |
My directory structure is like
When running
|
Similar issue: I have the problem where Jest gets stuck Update This happens sometimes without anything being broken at all. The tests will all pass, but then running with --watch will hang indefinitely. Adding a useless commit (changing whitespace or something) will be enough to get things moving again in watch mode. |
@jtulk Could you try going to |
@ashtonsix Sweet - that works perfectly. Thank you! |
Here you go:
Well, we have a large codebase with a very complicated jest config. The module/dependency resolver is touching files that are not covered by any test files at all (why is it trying to resolve dependencies for |
I'm having a similar problem with moduleNameMapper.
When I did that, jest apparently starts to look at all files under Obs: I can be sure that shared in |
I'm having the same issue, with the moduleNameMapper jest --watch hangs. Adding the console.error in the jest-resolve didn't show anything. My project structure is like this:
Update: Realised I was running global jest command - so my changes had no effect. Update#2: Seems like the problem comes from this:
Update 3: ;) But in a real dynamic import scenario, how can this be solved? |
Today I added one more line in UPDATESorry, I was wrong! The reason that my test is running fine is that no tests are running because I didin't change any files covered by tests. |
Having same problems when specifying items under
|
It's hard to test it without a downloadable repro. Can you provide one? |
FWIW, I was encountering this as well. I expanded the console logging to be:
In doing this I noticed that |
@ashtonsix Thanks, your suggestion helped me pinpoint the issue (in my case I had to add some submodules to @thymikee With these steps multiple people could repro, but 1 person wasn’t, so there’s something additionally different in their env. There’s a good chance you’d be able to repro it, though, so if you checkout our repo at artsy/emission@5038138, then perform these steps:
|
Thanks @alloy, I'll have a look |
I can definitely repro that, still no idea what's the case :D |
I am encountering a similar issue. Running I am using I tried suggestion #4883 (comment) and a bunch of errors that mapped module is not found pops out indeed. However, once again, it does work when watching in the other mode then 'changed only'. How is there such a huge difference? |
FWIW, I followed the suggested comment #4883 as well to log resolver errors to the console. I noticed in the logs the test runner was loading some legacy modules in my project that I thought I had deleted during a refactor that were trying to import other modules that had actually been deleted. This was causing a "Module not found" error. Deleting any old files that were attempting to import non-existing files fixed the issue for me. Update: I should add that I am also using |
@ashtonsix thanks! I was able to get enough context with the console log. It was picking up code in a vscode plugin under the It only seems to look in P.S. I tried using the following to configure jest with no luck:
|
@justin-calleja I'm having the same issue. Have you figured out how to configure jest to correct it? I'd like to avoid moving my .history out of my project directory if possible. |
@swcisel nope sorry. I deleted my .history. I don't really use it. It wasn't worth playing around with jest to get it to ignore .history. AFAIC, this is a bug in jest's watch mode - I don't see why I should configure it to ignore hidden directories - why would I put tests in hidden directories!? |
This should be fixed by #6407. Please let me know otherwise |
It is great that I could know why my I'm sorry it's off topic |
Same question as @KagamiChan. I have deleted a module physically. If I try to search for that module, it's not in my source code. Does --watch remember the the old mappings? Is there a way to clean up any cache it might have? |
same issue here... $ node scripts/test.js --env=jsdom --notify Configuration error: Could not locate module @/types/i18next mapped as: Please check your configuration for these entries: I tested it with the latest JEST 23.5.0 @thymikee any workaround or how can I help to fix this issue? |
I've just encountered the problem. Only happens in Version info: |
Did you delete the test coverage folder? |
Huh. I was messing with another problem earlier and was just nuking lock files, node_modules and my build folder, and never went back to check this particular problem. But I bet that was it. |
I've identified this to be a configuration issue. We didn't have |
I'm seeing this with create-react-app, where |
I'm having this issue now. Here is the error after injecting some console.error statements: Error: Cannot find module 'jest-environment-/fm/fm-api/tests/setup/mongo-environment.js' from '/fm/fm-api'
at resolveSync (/fm/fm-api/node_modules/jest-resolve/build/defaultResolver.js:119:15)
at defaultResolver (/fm/fm-api/node_modules/jest-resolve/build/defaultResolver.js:71:10)
at Function.findNodeModule (/fm/fm-api/node_modules/jest-resolve/build/index.js:112:14)
at resolveWithPrefix (/fm/fm-api/node_modules/jest-config/build/utils.js:158:39)
at getTestEnvironment (/fm/fm-api/node_modules/jest-config/build/utils.js:204:3)
at normalize (/fm/fm-api/node_modules/jest-config/build/normalize.js:569:59)
at readConfig (/fm/fm-api/node_modules/jest-config/build/index.js:163:46)
at readConfigs (/fm/fm-api/node_modules/jest-config/build/index.js:372:26)
at /fm/fm-api/node_modules/@jest/core/build/cli/index.js:155:58
at Generator.next (<anonymous>) {
code: 'MODULE_NOT_FOUND'
}
Error: Cannot find module 'jest-sequencer-@jest/test-sequencer' from '/fm/fm-api'
at resolveSync (/fm/fm-api/node_modules/jest-resolve/build/defaultResolver.js:119:15)
at defaultResolver (/fm/fm-api/node_modules/jest-resolve/build/defaultResolver.js:71:10)
at Function.findNodeModule (/fm/fm-api/node_modules/jest-resolve/build/index.js:112:14)
at resolveWithPrefix (/fm/fm-api/node_modules/jest-config/build/utils.js:158:39)
at getSequencer (/fm/fm-api/node_modules/jest-config/build/utils.js:262:3)
at normalize (/fm/fm-api/node_modules/jest-config/build/normalize.js:1012:54)
at readConfig (/fm/fm-api/node_modules/jest-config/build/index.js:163:46)
at readConfigs (/fm/fm-api/node_modules/jest-config/build/index.js:372:26)
at /fm/fm-api/node_modules/@jest/core/build/cli/index.js:155:58
at Generator.next (<anonymous>) {
code: 'MODULE_NOT_FOUND'
} It looks like Jest is replacing parts of the module names with other modules or paths. Any ideas? uname -a
|
@grantcarthew if you can create a repo with a minimal repro we can download, feel free to create a new issue |
Hi @thymikee, it is a private project so I can't really upload it to a public repository. This is still an issue and is becoming more so. At home I run a desktop with Debian Unstable. This was the first machine I saw the issue. I just upgraded my dev virtual machine on my laptop to Debian Buster. It now has the same issue. It looks like it is an issue with Buster and my setup. Buster was released on the 4th July, so it is only new. |
I tried removing the --watch parameter and now it writes |
I've found the cause. |
I've raised an issue with the |
for me the error message reveals itself after I moved a .ts file to another directory. @dereklin deleting the test coverage folder worked for me thx :) |
Okay, I just added |
For me, |
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. |
Bug
jest --watch
was getting stuck atDetermining test suites to run...
and stopped doing anything.I started debugging
ResolveDependencies.resolver.getMockModule
inside thejest-resolve
package and noticed nothing was getting logged after it was called with a dependency path that failed to map. I fixed the issue by creating the missing files - but tracking down this bug took much longer than it should & it'd have been great to see a helpful error (issues others encountered related towatchman
turned out to be red herrings).Expected behavior
I should have seen this error when running
jest --watch
:Config + details
21.0.2
8.5.0
4.6.1
16.04
Issue not encountered at all when using
--watchAll
My colleagues are using Ubuntu
17.10
& MacOS Sierra but they didn't encounter this issue (or see any related issues).I think the tests which relied on unmocked meteor libraries were skipped (explaining the apparent lack of errors in some circumstances).
The text was updated successfully, but these errors were encountered: