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
Agent Lightning
AI Development
A Microsoft-built training framework that optimizes AI agents with reinforcement learning, automatic prompt optimization, or supervised fine-tuning — with near-zero code changes to your existing agent, in any framework.
Appsmith
Developer Tools · Automation · No Code Platforms
Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.
Budibase
Low Code Platforms · No Code Platforms
Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.
ByteChef
Automation · AI Agents
Unified open-source platform for AI agent orchestration and workflow automation with 180+ connectors, MCP support, and durable execution.
CourseLit
Ecommerce · Blogging
Open-source, self-hosted LMS for selling online courses, digital downloads, and building communities on your own branded website.
Element Web
Team Chat · Collaboration
A polished, self-hostable Matrix client for secure, decentralized messaging and collaboration that puts your organization in full control of its data.
Grafana
Monitoring · Analytics
The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.
GrowthBook
Developer Tools · Analytics · Monitoring
Open source feature flags, A/B testing, and warehouse-native experimentation that queries your existing data infrastructure—no data movement required.
Harness Open Source
Developer Tools · Devops · Code Editors
A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.