identity-obj-proxy

An ES6 Proxy that echoes back every key you access, built to mock CSS Modules and other webpack style imports in Jest tests.

Library
npm
v3.0.0
507 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
29 /100 Needs Attention
Development Activity 0
Maintenance 0
Community 36
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
56 /100 Fair
Architecture 70
Code Quality 60
Innovation 50
Learning Curve 45

identity-obj-proxy exports a single object built with the native ES6 Proxy — accessing any property or key on it simply returns that key back as a string. That trivial behavior turns out to be exactly what’s needed to mock CSS Modules and similar webpack loader imports inside Jest: instead of styles.root resolving to undefined under Jest’s Node environment, it resolves to 'root', so component snapshots stay readable and class-name assertions keep working without a real webpack build.

The library is intentionally minimal — a single src/index.js file with one dependency (harmony-reflect, used only as a Proxy polyfill for pre-v6 Node). It’s wired into a test setup via Jest’s moduleNameMapper config, mapping CSS/SCSS/LESS imports to identity-obj-proxy so tests never touch real stylesheets.

What You Get

  • A ready-made Proxy object that returns the accessed property/key as a string, with no setup beyond installing the package
  • Correct interop with Babel’s ES6 default-import/export transpilation, including a special-cased __esModule key so import/require both work
  • A harmony-reflect fallback so the Proxy behavior works even on Node versions predating native Proxy support
  • Zero configuration surface — the module has no options, flags, or API beyond the exported object itself

Common Use Cases

  • Mapping .css/.scss/.less imports to this package via Jest’s moduleNameMapper so CSS Modules class names resolve during tests
  • Keeping Jest snapshot tests of React/Vue components readable by returning real class-name strings instead of undefined
  • Mocking any other webpack-loader-driven import (SVGs, fonts, JSON-like assets) that isn’t relevant to the unit under test
  • Standing in as a lightweight identity mock in any test harness that needs an object whose property access never throws or returns undefined

Under The Hood

Architecture

The entire library is one file, src/index.js, exporting a single object built with new Proxy({}, { get: getter }); the get trap returns whatever key is accessed, coerced to a string, with one special case — returning false for __esModule so Babel’s ES6-interop checks treat the proxy as a plain CommonJS export rather than an ES module. A test-redirections/ directory holds tiny wrapper files that re-export the same proxy through every combination of import/require and default/named export syntax, and a matching set of __tests__ specs exercises each combination — so despite having almost no code, the module is deliberately structured to guarantee consistent behavior across a project’s mixed module styles.

Tech Stack

Plain ES5-compatible JavaScript with harmony-reflect as the sole runtime dependency, loaded conditionally only on Node versions below 6 that lack native Proxy support. The dev toolchain is an older Babel 6 setup (babel-core, babel-preset-es2015, babel-preset-stage-0) used solely to transpile the ES6-syntax test files, Jest (jest-cli) as the test runner, ESLint with the airbnb-base config for linting, and Travis CI plus Coveralls wired into npm run prepublish for lint/test gating before every publish. There’s no build step for the shipped module itself — package.json’s main points straight at the unbundled src/index.js.

Code Quality

Test coverage is unusually thorough relative to the library’s size: ten Jest specs cover every ES6/CommonJS import-export permutation to guard specifically against Babel-interop regressions, and npm run prepublish runs lint plus the full suite before any release. There is no type system (plain JavaScript, no TypeScript or Flow) and essentially no error-handling surface, since the proxy’s get trap has no failure path by design. Naming is minimal and generic (idObj, getter), appropriate to the module’s narrow scope.

API Design The entire public surface is one exported value with no functions, options, or configuration — a consumer’s only integration point is mapping an import path to this package in a bundler or Jest’s moduleNameMapper. That zero-API design is the whole point: it makes adoption a one-line config change, at the cost of the library being usable for exactly one narrow purpose and nothing else.

Used by 27 apps in this directory

Go
33%

OpenPanel

Devops · Hosting Control Panel

750

Docker-powered web hosting control panel that gives every user a fully isolated environment with dedicated web server, database, and networking — VPS-grade security on shared hardware.

View details
84
Repo Health
75
Technical
63
Dependency
Built with
Go 33%
HTML 31%
TypeScript 26%
Updated 2 weeks ago
TypeScript
89%
MIT

Plasmic

CMS · Design Tools · Low Code Platforms

7,082

The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.

View details
81
Repo Health
78
Technical
64
Dependency
Built with
TypeScript 89%
Updated 2 weeks ago
Python
45%
Other

Redash

Analytics · Data Engineering

28,831

Redash lets anyone connect to 35+ SQL and NoSQL data sources, write a query in the browser, and turn the result into a shared dashboard — no separate BI suite required.

View details
91
Repo Health
74
Technical
60
Dependency
Built with
Python 45%
JavaScript 29%
TypeScript 19%
Updated 2 weeks ago
TypeScript
97%
AGPL 3.0

Responsively App

Design Tools · Developer Tools

25,234

Preview and interact with your responsive web design across every device size simultaneously — no more manual resizing.

View details
82
Repo Health
71
Technical
66
Dependency
Built with
TypeScript 97%
Updated 2 weeks ago
TypeScript
97%
Other

Rocket.Chat

Team Chat

46,240

The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.

View details
96
Repo Health
79
Technical
66
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
TypeScript
83%
AGPL 3.0

Standard Notes

Note Taking

6,648

End-to-end encrypted notes and files — private by design, built to last, and fully self-hostable.

View details
89
Repo Health
83
Technical
68
Dependency
Built with
TypeScript 83%
JavaScript 14%
Updated 2 weeks ago
TypeScript
98%
Apache 2.0

TinaCMS

CMS

13,824

An open-source, Git-backed headless CMS that gives editors a live visual editing UI over Markdown, MDX, JSON, and YAML content while developers keep everything in version control.

View details
92
Repo Health
74
Technical
59
Dependency
Built with
TypeScript 98%
Updated 2 weeks ago
Python
70%
AGPL 3.0

Tracecat

AI Agents · Automation · Security

3,830

Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.

View details
89
Repo Health
88
Technical
66
Dependency
Built with
Python 70%
TypeScript 29%
Updated 2 weeks ago
JavaScript
75%
AGPL 3.0

Twake Drive

Collaboration · File Storage

988

Open-source, self-hosted file manager with collaborative drives, AI-powered summarization, and OnlyOffice document editing for teams who want full data sovereignty.

View details
91
Repo Health
78
Technical
71
Dependency
Built with
JavaScript 75%
TypeScript 24%
Updated 2 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers