Skip to content
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

Provide first-class support for CRA #90

Closed
nvh95 opened this issue Apr 25, 2022 · 1 comment · Fixed by #102
Closed

Provide first-class support for CRA #90

nvh95 opened this issue Apr 25, 2022 · 1 comment · Fixed by #102
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement Enhancement to current features/ behaviors feature request Request a new feature

Comments

@nvh95
Copy link
Owner

nvh95 commented Apr 25, 2022

Describe the bug
There are several issues with CRA, all of them related to that we couldn't modify jest's config freely (see how CRA overrides config here https://github.com/facebook/create-react-app/blob/63bba07d584a769cfaf7699e0aab92ed99c3c57e/packages/react-scripts/scripts/utils/createJestConfig.js#L94-L107 ):

  1. (CSS Modules) We couldn't support CSS Modules since we cannot remove
moduleNameMapper: {
-  '^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
},

(Can we add a module, instead of identity-obj-proxy, we keep the original behavior?)

  1. (Sass) If we configure cssTransform like this:
transform: {
  "^.+\\.(css|scss|sass)$": "jest-preview/transforms/css",
},

Preview won't have CSS, the reason is "^.+\\.(css|scss|sass)$" doesn't replace "^.+\\.css$": resolve('config/jest/cssTransform.js'), so "^.+\\.css$": resolve('config/jest/cssTransform.js') still take place

transform: {
  "^.+\\.css$": resolve('config/jest/cssTransform.js'),
},

One workaround to make both .css, .scss, .sass work is to configure like this:

"transform": {
  "^.+\\.css$": "jest-preview/transforms/css",
  "^.+\\.(css|scss|sass)$": "jest-preview/transforms/css",
},

To Reproduce

  • CSS Modules issue: any repo
  • Sass: configure like this
"^.+\\.(css|scss|sass)$": "jest-preview/transforms/css",

Expected behavior
Jest Preview should work with CRA out of the box

Others

@nvh95 nvh95 added bug Something isn't working documentation Improvements or additions to documentation enhancement Enhancement to current features/ behaviors feature request Request a new feature labels Apr 25, 2022
@nvh95
Copy link
Owner Author

nvh95 commented Apr 25, 2022

@nvh95 To update docs to mention case when Sass might not work

@nvh95 nvh95 linked a pull request May 15, 2022 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement Enhancement to current features/ behaviors feature request Request a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant