72tfrw
Last Updated: March 07, 2016
·
176
· angelathewebdev
03ba33ccbb0ef8b3849096c1fe8f48e6

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

Say Thanks
Respond