-
Notifications
You must be signed in to change notification settings - Fork 156
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
Doesn't resolve with babel-plugin-module-resolver files in SFCs #13
Comments
I'm sorry I haven't been able to debug this. A temporary solution is to use Jest moduleNameMapper. You can add this to your Jest config field:
|
I believe it's slightly more complicated than that, because the module-resolver plugin is running, but the path resolution is incorrect. In case anyone else stumbles across this, my solution was to use: "moduleNameMapper": {
"^\\./resources/assets/js/(.*)$": "<rootDir>/resources/assets/js/$1",
} Or you could disable the babel plugin in env.test and then do what you said above, but that's currently a bit more confusing because of the weird way envs are merged in a json babelrc. But I'm getting by just fine with this workaround, so no hurry! Thanks for the response! |
Can confirm this bug. |
Hi @eddyerburgh I am looking to find out what is a |
haste is a Facebook module resolver. They just moved Facebook away from it, so they may be planning to move Jest away too. https://github.com/facebookarchive/node-haste/tree/master Thanks for looking into this by the way 😀! |
No problem :) What would you suggest to do about this? |
Just ran into this problem today. I was able to come up with a somewhat clean solution. My setup includes: babel, jest, babel-jest, vue-jest. This is the relevant portion of my
Without this, using the module aliases in SFCs did not work when running tests. The only entry in Does anyone know if something like this should/could be automatically supported by vue-jest?. I would be happy to look at making a pull request if it seemed like something that made sense to automatically handle. |
Hi! I am the main one maintaining this project nowdays. Is this still an issue? I'm guessing so - isn't the solution just to use jest moduleMapper? Not sure this is something vue-jest should be doing. |
A component that imports from an alias with
babel-plugin-module-resolver
will fail to resolve in jest. Seems like it's not resolving./
as the babel cwd, but from the component location.Example
.babelrc:
src/components/A.vue:
src/components/B.vue:
Result:
The text was updated successfully, but these errors were encountered: