Skip to content

Instantly share code, notes, and snippets.

@ryanseddon
Created October 9, 2015 05:44
Show Gist options
  • Save ryanseddon/e76fd16af2f8f4f4bed8 to your computer and use it in GitHub Desktop.
Save ryanseddon/e76fd16af2f8f4f4bed8 to your computer and use it in GitHub Desktop.
Mocha compiler for css-module support in tests using sass
mocha --compilers js:babel/register,js:./test/css-modules-compiler.js --recursive -w
var hook = require('css-modules-require-hook');
var sass = require('node-sass');
hook({
extensions: ['.scss'],
preprocessCss: function (css) {
var result = sass.renderSync({
data: css
});
return result.css;
}
});
@potapovDim
Copy link

node_modules/node-sass/lib/index.js:420
throw util._extend(new Error(), JSON.parse(result.error));
^

Error: Undefined variable: "$font-logo".

@rpoitras
Copy link

@stipsan and @ryanseddon thank you very much for taking the time to share!

@jhohlfeld
Copy link

As of babel 6 it's rather mocha --compilers js:babel-core/register,js:./test/css-modules-compiler.js

babel-core instead of just 'babel`

@thetallweeks
Copy link

Has anyone had issues with empty css files throwing?

throw new Error('No input specified: provide a file name or a source string to process');

It's coming from an external dependency so I can't remove the file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment