-
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
svgr + jest not configured #4850
Comments
Actually, jest misses a lot of other loaders' support. Here is my modified jest.config.js in each app/lib dir:
Hope it will help 🙏️ |
Thanks @quolpr but we got a lot of libs. Not ideal to need to manually modify each of them and to try and get everyone in the team to remember to manually change it when creating a new lib. Best to have it as part of nx, or to have some script in tools/scripts dir If nx team doesn't respond soon, I'll probably end up making a script for it |
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
This is still an isssue... |
@vsavkin Can you please reopen it? |
this worked for me although this should be default behaviour from NX |
there is svgr (and also font) support it seems in the gatsby jest setup, but not for default react libs. Would be nice to have an overview in the docs of what is supported where (with webpack, jest, rollup, babel) and what is the best way to customize without overriding defaults. Now the only way is to look at the source files of the nx presets. |
For those who interested in workaround:
Please note two /.. after root dir. Due to #8029 all libs folders are using their src as rootDir
|
@Lonli-Lokli I've tried your approach and still cannot get around the error: // error TS2307: Cannot find module './brand-icon.svg' or its corresponding type declarations.
import { ReactComponent as BrandIcon} from './brand-icon.svg'; |
I've answered in linked topic. |
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. |
Current Behavior
@nrwl/next/plugins/with-nx
allows us to usesvgr
to import svg's. When running unit tests on components (inside libs), however, this does not go via next.config.js so we need to manually setup jest to handle svgr for each and every library's jest.config.jsExpected Behavior
I expect some sort of jest config baked into the generator
Steps to Reproduce
nx g @nrwl/react:lib myLib
libs/my-lib/assets/my-svg.svg
my-lib.tsx
file and import the svgnx myLib:test
and see how jest falls overFailure Logs
Environment
The text was updated successfully, but these errors were encountered: