Deprecated: Creation of dynamic property ET_Builder_Module_Comments::$et_pb_unique_comments_module_class is deprecated in /home/softcrea/public_html/wp-content/themes/Divi/includes/builder/class-et-builder-element.php on line 1425

Jest: Ignore CSS files while running tests

by | Dec 12, 2018 | General | 0 comments

Written By Ola Ajibode

To ensure Jest ignores CSS files when running tests, simply follow the steps below:

  1.  Install a module: `identity-obj-proxy`
npm install -D identity-obj-proxy

2.   Update your jest config(jest.config.json)

{
  "jest":{
     "moduleNameMapper": {
      "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/__mocks__/fileMock.js",
      "\\.(css|less|scss|sass)$": "identity-obj-proxy"
    },
  }
}

Now run your tests again.   You should not see failures due to CSS files anymore.

Written By Ola Ajibode

undefined

Explore More Insights

Docker:  Stop all containers now!

Docker: Stop all containers now!

Docker has changed our world. A very useful component in the toolbox of any Software Engineer or perhaps, any forward-thinking company. What is Docker? Why Docker? and other questions relating to the topic starts here: Docker Sometimes, you are just too annoyed with...

read more
Elasticsearch Cleansing

Elasticsearch Cleansing

By running a custom-built Elasticsearch on AWS, you have to do everything on the console.   AWS has its Elasticsearch offering but I had this project handed over to me and it's running an old instance of Elasticsearch before AWS had its own. Data pollution is a common...

read more

0 Comments

Submit a Comment