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.
Repository Health
Technical Analysis
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
__esModulekey soimport/requireboth work - A
harmony-reflectfallback 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/.lessimports to this package via Jest’smoduleNameMapperso 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
OpenPanel
Devops · Hosting Control Panel
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.
Plasmic
CMS · Design Tools · Low Code Platforms
The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.
Redash
Analytics · Data Engineering
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.
Responsively App
Design Tools · Developer Tools
Preview and interact with your responsive web design across every device size simultaneously — no more manual resizing.
Rocket.Chat
Team Chat
The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.
Standard Notes
Note Taking
End-to-end encrypted notes and files — private by design, built to last, and fully self-hostable.
TinaCMS
CMS
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.
Tracecat
AI Agents · Automation · Security
Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.
Twake Drive
Collaboration · File Storage
Open-source, self-hosted file manager with collaborative drives, AI-powered summarization, and OnlyOffice document editing for teams who want full data sovereignty.