You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My tests are not capturing my html class names when using CSS Modules, this is despite using moduleNameMapper and identity-obj-proxy for my .scss files in my jest.config.js.
To Reproduce
Clone this repo.
Run yarn.
Run yarn test sampleComponent.test.tsx.
Expected behavior
The test should pass.
Instead, it fails because it is unable to find the class name associated with the div.
sampleComponent.tsx:
import*asReactfrom'react';importstylesfrom'./sampleComponent.module.scss';constSampleComponent: React.FC=()=>(<divclassName={styles.foo}>
Hello World
</div>);exportdefaultSampleComponent;
This is because you import default from the SCSS file instead of import *.
You can see that logging the imported object prints 'default'.
You can use a named import or look for other solutions e.g. in keyz/identity-obj-proxy#8
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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
🐛 Bug Report
My tests are not capturing my html class names when using CSS Modules, this is despite using
moduleNameMapper
andidentity-obj-proxy
for my.scss
files in myjest.config.js
.To Reproduce
Clone this repo.
Run
yarn
.Run
yarn test sampleComponent.test.tsx
.Expected behavior
The test should pass.
Instead, it fails because it is unable to find the class name associated with the div.
sampleComponent.tsx:
sampleComponent.test.tsx:
test output:
jest.config.js:
Link to repo
Run
npx envinfo --preset jest
The text was updated successfully, but these errors were encountered: