javascript - How to exclude CSS module files from jest test suites? -
i have react component test, import css using webpack following.
import styles '../../node_modules/openlayers/css/ol.css' // eslint-disable-line no-unused-vars after running jest error:
c:\users\...\node_modules\openlayers\css\ol.css:1 ({"object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){.ol-box { ^ syntaxerror: unexpected token . how exclude css files jest test suites?
you can create own mock in jest prevent processing of css files.
// __mocks__/stylemock.js module.exports = {}; then in package.json can map css files stylemock.js file under modulenamemapper option:
"jest": { ... "modulenamemapper": { ... "\\.(css|less)$": "<rootdir>/__mocks__/stylemock.js" }, .. }, see https://facebook.github.io/jest/docs/en/webpack.html#handling-static-assets more info.
Comments
Post a Comment