-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unable to get css classes injected in element with scss and css modules. #235
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
Comments
Jest config does not work in codesandbox, but here's what I think the problem is: This is your
This means all style imports are replaced with an empty object. Instead of this mock, you can point to a module called // in jest.config.js
moduleNameMapper: {
".+\\.(css|scss)$": "identity-obj-proxy"
}, It looks like this module is already in package.json. |
Also, when I download the project locally it appears that react-scripts ts is not using all the options in your jest.config.js. It looks like only a few properties are supported for overrides: https://facebook.github.io/create-react-app/docs/running-tests#configuration To get around this you may need to follow the instructions to eject from create-react-app, or run jest directly and copy in any missing config that CRA set up for you (e.g. setupTests.js). |
Closes testing-library#306 Closes testing-library#301 Closes testing-library#235 Closes testing-library#181 Closes testing-library#172 Closes testing-library#31
…ary#308) Closes testing-library#306 Closes testing-library#301 Closes testing-library#235 Closes testing-library#181 Closes testing-library#172 Closes testing-library#31
react-testing-library
version: 5.3.1react
version: 16.6.3node
version: 10.4.1npm
version: 6.4.1Reproduction:
Here's the Codesandbox: https://codesandbox.io/s/xvw9r8z24z
In this codesandbox I can run my tests
However, in this codesandbox I have the project setup: https://codesandbox.io/s/r15r76o8y4
I can not run the project because of missing dependencies.
Problem description:
I had created another issue regarding not seeing classes in components that I was testing and I thought it was a problem how I was developing my components in storybook. However, I've tested a component in our project and I still have the same problem.
The component displays just fine with the classes when I run the project, however when I try to test my components and check if they have a class, the test fails.
I've tried to rename the file from .scss to css and instead of having className={s.active}, I'd have className="active" and the test would pass because the class was injected into the dive element.
I've been struggling with this, I don't know if it has to do with postcss or how scss files should be handled. I'm not getting any error when I run the text other than why the test is not passing.
In jest.config.js I've tried with the following settings:
"moduleNameMapper": {
".+\.(css|styl|less|sass|scss|svg)$": "/node_modules/jest-css-modules-transform",
},
but the result is the same.
@kentcdodds, I'm sorry to be a pain but do you think you could check my codesandbox and see if I'm doing something wrong the way I'm configuring jest with scss?
The text was updated successfully, but these errors were encountered: