Socket
Socket
Sign inDemoInstall

imitation

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

imitation

A simple Jest moduleNameMapper for non-code imports


Version published
Maintainers
1
Created

Readme

Source

Imitation

A simple Jest moduleNameMapper for non-code imports. It helps for testing stuff like CSS Modules and images.

Usage with Jest

npm i --save-dev imitation

Then set it up in your jest.config.js file:

{
  "jest": {
    // ... other config
    "moduleNameMapper": {
      "\\.(svg|png|jpg)$": "imitation/images",
      "\\.(scss|css)$": "imitation/styles"
    }
  }
}

Stylesheet files (CSS/SCSS/Less) will resolve to proxies that return any classname as itself (eg. styles.base resolves to 'base').

Anything else (ie. images or fonts or whatever) will resolve to the string "imitated".

Authors

  • Nathan Hoad - nathan@nathanhoad.net

Keywords

FAQs

Package last updated on 22 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc