{"id":13656987,"url":"https://github.com/keyz/identity-obj-proxy","last_synced_at":"2025-04-05T19:13:29.827Z","repository":{"id":41371422,"uuid":"48542140","full_name":"keyz/identity-obj-proxy","owner":"keyz","description":"An identity object using ES6 proxies. Useful for mocking webpack imports like CSS Modules.","archived":false,"fork":false,"pushed_at":"2022-01-29T03:32:40.000Z","size":12,"stargazers_count":503,"open_issues_count":11,"forks_count":18,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T18:08:39.305Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keyz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-24T12:37:59.000Z","updated_at":"2025-03-17T19:08:04.000Z","dependencies_parsed_at":"2022-07-30T07:37:58.191Z","dependency_job_id":null,"html_url":"https://github.com/keyz/identity-obj-proxy","commit_stats":null,"previous_names":["keyanzhang/identity-obj-proxy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keyz%2Fidentity-obj-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keyz%2Fidentity-obj-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keyz%2Fidentity-obj-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keyz%2Fidentity-obj-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keyz","download_url":"https://codeload.github.com/keyz/identity-obj-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246851627,"owners_count":20844219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T05:00:35.408Z","updated_at":"2025-04-05T19:13:29.801Z","avatar_url":"https://github.com/keyz.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# identity-obj-proxy [![Build Status](https://img.shields.io/travis/keyanzhang/identity-obj-proxy.svg?style=flat-square)](https://travis-ci.org/keyanzhang/identity-obj-proxy) [![npm version](https://img.shields.io/npm/v/identity-obj-proxy.svg?style=flat-square)](https://www.npmjs.com/package/identity-obj-proxy) [![test coverage](https://img.shields.io/coveralls/keyanzhang/identity-obj-proxy/master.svg?style=flat-square)](https://coveralls.io/github/keyanzhang/identity-obj-proxy?branch=master)\nAn identity object using ES6 proxies. Useful for mocking webpack imports. For instance, you can tell Jest to mock this object as imported [CSS modules](https://github.com/css-modules/css-modules); then all your `className` lookups on the imported `styles` object will be returned as-is.\n\n```\nnpm install identity-obj-proxy\n```\n\n## ~~Real world example~~ Wait what does that even mean\n### tl;dr\nFor a React component like\n```js\nimport React, { Component } from 'react';\n\nimport styles from './App.css'; // CSS Modules here\n\nexport default class App extends Component {\n  render() {\n    return (\n      \u003cdiv className={styles.root}\u003e\n        \u003ch1 className={styles.hello}\u003eHello, world!\u003c/h1\u003e\n      \u003c/div\u003e\n    );\n  }\n}\n```\n\nwe can generate a snapshot as below (notice that the class names get correctly mocked):\n```js\nexports[`test App renders correctly 1`] = `\n\u003cdiv\n  className=\"root\"\u003e\n  \u003ch1\n    className=\"hello\"\u003e\n    Hello, world!\n  \u003c/h1\u003e\n\u003c/div\u003e\n`;\n```\n\nFor more information, please take a look at https://github.com/keyanzhang/jest-css-modules-example/ and https://jestjs.io/docs/en/webpack.html.\n\n## Requirement\nNo flag is required for Node.js `v6.*`; use `node --harmony_proxies` flag for `v5.*` and `v4.*`.\n\n## Example\n``` javascript\nimport idObj from 'identity-obj-proxy';\nconsole.log(idObj.foo); // 'foo'\nconsole.log(idObj.bar); // 'bar'\nconsole.log(idObj[1]); // '1'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeyz%2Fidentity-obj-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeyz%2Fidentity-obj-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeyz%2Fidentity-obj-proxy/lists"}