-
Notifications
You must be signed in to change notification settings - Fork 19
Webpack Loader issue
Dave Brotherstone edited this page Nov 18, 2015
·
1 revision
This note is from @pl2133
I went to integrate this test setup into my project which is built on Webpack. As such my .js files sometimes include files loaded with webpack loaders; for example .png or .scss. Mocha throws a SyntaxError on encountering these, so you need a custom compiler.
My custom compiler src/tests/compiler.js:
'use strict'
var babel = require('babel-core/register');
function noop() {
return null;
}
require.extensions['.scss'] = noop;
require.extensions['.css'] = noop;
And new npm test command:
mocha --compilers js:./src/tests/compiler.js ./src/tests/*.spec.js