72tfrw
Last Updated: March 07, 2016
·
203
· angelathewebdev

Webpack and testing in Mocha

If you have inline file to test in Mocha and Mocha is generating an error about not knowing what to do with it, or a parsing error. Add the following to the setup.js

import fs from 'fs';

require.extensions['.svg'] = function (module, filename) {
   module.exports = fs.readFileSync(filename, 'utf8');
};

where svg can be the extension of your file names