-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
use babel-jest
instead of ts-jest when babel is used for compilation @nrwl/react
#1720
Comments
babel-jest
instead of ts-jest when babel is used for compilation @nrwl:react
babel-jest
instead of ts-jest when babel is used for compilation @nrwl/react
@Hotell , great suggestion. I'll add this to our features list. |
We are also having issue with this. Our tests stoped working once we introduced linguijs i18n library which uses babel macros. @Hotell @jaysoo is there any way to extend or configure jest builder to use babel-jest with the same babel config that web build and dev-server builders are using or I have to write completely new builder? |
@jbojcic1 You can swap out
|
@jaysoo are there other things i have to tweak? changing to babel-jest solely in the root folder breaks the test and gives me this error ● Validation Error: Module babel-jest in the transform option was not found. |
@wuichen Make sure you also install
Once we update our schematics to use |
Bringing in @Cammisuli as a second set of eyes on this. 👀 I haven't given this enough thought yet, but I definitely see a need to use
#1 would be the easiest option since the changes required are minimal. For #2 to work, we'll have to pull in more dev dependencies, such as |
I'm in favour of option 2. Why?
|
@jaysoo it's not enough to just swap ts-jest with babel-jest because currently nx is setting all babel plugins and presets in the webpack config as babel-loader options. When running tests with babel-jest webpack is not used. I ended up creating .babelrc.js in my app root and specified babel presets and plugins there. There is one caveat though. If you have some plugins that you need when running the app but not when running the tests, those plugins have to be added to webpack babel-loader options by extending webpack config and injecting it there. Regarding the potential options, I agree with @Hotell |
@jbojcic1 Yes, you will unfortunately have to duplicate babel settings for now. It sounds like supporting |
@jaysoo what is the status of this? perhaps I could give it a try if it hasn't been started yet? |
When I used |
@jbojcic1 If you want try it out please feel free We will need to investigate further, and unfortunately we currently have other issues taking priority. Contribution notesOnce you've made your changes you can test out with:
This will take a while, but eventually you can cd into
To update the playground when you make changes to Nx, run:
|
This is still an issue AFAICT |
Hi, sorry about this. This was mislabeled as stale. We are testing ways to mark not reproducible issues as stale so that we can focus on actionable items but our initial experiment was too broad and unintentionally labeled this issue as stale. |
This was already implemented so I should probably close this #2722 |
I've added a PR to make this the default behaviour when generating a project (app or lib) with the |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Expected Behavior
yarn nx g @nrwl/react:app with-babel --babel=true --linter=eslint
should generate app that uses babel for compilation. eslint for linting and
babel-jest
for running transforms within jest instead ofts-jest
which is deprecated and quite slowCurrent Behavior
ts-jest
is always used for libraries and appsContext
Please provide any relevant information about your setup:
8.4.8
The text was updated successfully, but these errors were encountered: