-
-
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
[request] babel-jest support custom path for .babelrc #3845
Comments
You can use |
@thymikee @ejfrancis But even if I moved jest config, I still can't move my Correct me if I'm wrong. I think this issue should be reopened. I'll gladly write a PR if you agree with my arguments. |
I'll reopen, because that's something we should easily allow (so you don't have to write custom transformer). What's your idea to resolve this? |
"test" env didn't work for me, had to use snippet from #5324 |
I need this feature too. I put the npm script tests inside of a node module dependency. When I run it, it loses the .babelrc file:
I think it is because I changed the |
AFAIU, the best way is to do the same as in "ts-jest" — to create "babel-jest" section inside the "global" section of jest config file and define there a path to .babelrs: {
"globals": {
"babel-jest": {
"babelrcFile": "custom/path/to/.babelrc"
}
},
} Then we will need to modify the @thymikee I would be very grateful if you explain to me how the transformers are invoked, how and where the functions |
I also would love a way to do this without a custom transformer (haven't gotten that working). |
I wonder if babel/babel#7472 is enough after we upgrade to babel 7 - if babel can find your config then jest should be able to find your config (unless I misunderstand something) |
#1468 (comment) this solution work well |
This is also needed if you're working with Meteor where you typically have no |
Any movement on this? It's become doubly important since the addition of Babel 7's wonky config-lookup strategy. |
@bsmith-cycorp That will require this PR: #7016 |
I ended up just doing the hack suggested by @zzuhan. It made me die a little bit inside, but it works. |
For me tests is working with babel but build and run the code is not using babel at all. So the temporary solution I use is to move .babelrc to config folder and rename to tests.babelrc then in package.json I did changes like this
and works well |
I think a custom transformer using Docs: https://jestjs.io/docs/en/tutorial-react#custom-transformers To be able to pass config to |
Just as a follow up, for who runs into this. If you are supplying your custom babel config to webpack, as opposed to running it from
|
I have my babel.config.js inside a config folder which is not grabbed by Jest. Is there anything I could do to tell Jest the path? Thank you in advance and regards. |
Check the docs? The example there is |
Thanks @SimenB !! It worked :) That was a long shot, I would not had figured it out just by reading the docs. |
Hi all, I fix like this after Simen tip: jest.config.js module.exports = {
transform: {
'\\.js$': ['babel-jest', { configFile: './Configuration/babel.config.js' }]
},
roots: ['../']
}; babel.config.js presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
]
] An example maybe can help someone in the future. |
This works like a charm <3 <3 thanksssss! |
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. |
An option to provide an alternative path to the
.babelrc
file thatbabel-jest
uses would be helpful. I'd like to use a.babelrc
in my tests that isn't used in the build of my application code.The text was updated successfully, but these errors were encountered: