-
Notifications
You must be signed in to change notification settings - Fork 180
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
Unit tests #5
Comments
You could mock out the Or add css-modules-require-hook and actually load the CSS: https://github.com/css-modules/css-modules-require-hook Will either of these methods work for you? |
The require hook option should work. I'll let you know how it went. |
I'm using jest with webpack, made a preprocessor.js like below, just ignoring css files
Of course I would get |
@davidpfahler did this work for you?
where .voteButton {
composes: large from "./typography.css";
} and .large {
font-size: 1.5rem;
} Update: created css-modules/css-modules-require-hook#38 |
@sebastienbarre Sorry for not responding for a while on this. In the project I was using css-modules (rebox-react) we moved from css files to style attributes, because we had issues with using this with react-transform. |
Thanks @davidpfahler ; with respect to your issue with
and in import jsdom from 'jsdom';
const doc = jsdom.jsdom('<!doctype html><html><body></body></html>');
const win = doc.defaultView;
global.document = doc;
global.window = win;
Object.keys(window).forEach((key) => {
if (!(key in global)) {
global[key] = window[key];
}
}); |
Here's one way to Mocha test React w/ CSS Modules: https://gist.github.com/mmrko/288d159a55adf1916f71 |
@chenxsan Got any solutions for that ? I am also having the same problem... |
@chenxsan Seems got the solution for that... Look at this and give me some suggestions Use the code inside the //Imports
|
How would you do unit tests with css-modules / css-loader?
I love the idea of css-modules but am struggling with testing as node cannot require css. I'm very thankful for any answer or idea.
The text was updated successfully, but these errors were encountered: