Socket
Socket
Sign inDemoInstall

identity-obj-proxy

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    identity-obj-proxy

an identity object using ES6 proxies


Version published
Weekly downloads
6.1M
increased by1.5%
Maintainers
1
Install size
96.5 kB
Created
Weekly downloads
 

Package description

What is identity-obj-proxy?

The identity-obj-proxy package is primarily used for mocking module exports in JavaScript tests. It's especially useful when working with CSS Modules in a Jest testing environment, as it allows you to proxy the imported CSS Modules with an identity object that returns the module's name for any property access. This way, tests can be run without having to worry about the actual CSS and focus on the JavaScript logic.

What are identity-obj-proxy's main functionalities?

Mocking CSS Modules in Jest

This code snippet demonstrates how to mock a CSS module import using identity-obj-proxy in a Jest test. It replaces the actual styles with an object that has the same keys as the class names defined in the CSS file, but with values equal to the keys themselves.

jest.mock('styles.module.css', () => require('identity-obj-proxy'));

Other packages similar to identity-obj-proxy

Readme

Source

identity-obj-proxy Build Status npm version test coverage

An identity object using ES6 proxies. Useful for testing trivial webpack imports. For instance, you can tell Jest to mock this object as imported CSS modules; then all your className lookups on the imported styles object will be returned as-is.

npm install identity-obj-proxy

Requirement

No flag is required for Node.js v6.*; use node --harmony_proxies flag for v5.* and v4.*.

Example

import idObj from 'identity-obj-proxy';
console.log(idObj.foo); // 'foo'
console.log(idObj.bar); // 'bar'
console.log(idObj[1]); // '1'

Keywords

FAQs

Last updated on 03 Aug 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc