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
507stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
29/100Needs Attention
Development Activity0
Maintenance0
Community36
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
56/100Fair
Architecture70
Code Quality60
Innovation50
Learning Curve45

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

Python
98%
MIT

Agent Lightning

AI Development

18,000

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.

View details
83
Repo Health
68
Technical
70
Dependency
Built with
Python98%
Updated 5 days ago
TypeScript
68%
Apache 2.0

Appsmith

Developer Tools · Automation · No Code Platforms

40,825

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
TypeScript68%
Java21%
Updated 3 days ago
TypeScript
69%
Other

Budibase

Low Code Platforms · No Code Platforms

28,260

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
91
Repo Health
81
Technical
63
Dependency
Built with
TypeScript69%
Svelte26%
Updated 2 days ago
Java
73%
Other

ByteChef

Automation · AI Agents

1,000

Unified open-source platform for AI agent orchestration and workflow automation with 180+ connectors, MCP support, and durable execution.

View details
85
Repo Health
82
Technical
70
Dependency
Built with
Java73%
TypeScript26%
Updated yesterday
TypeScript
93%
AGPL 3.0

CourseLit

Ecommerce · Blogging

1,262

Open-source, self-hosted LMS for selling online courses, digital downloads, and building communities on your own branded website.

View details
75
Repo Health
74
Technical
71
Dependency
Built with
TypeScript93%
Updated 1 months ago
TypeScript
94%
AGPL 3.0

Element Web

Team Chat · Collaboration

13,437

A polished, self-hostable Matrix client for secure, decentralized messaging and collaboration that puts your organization in full control of its data.

View details
96
Repo Health
83
Technical
65
Dependency
Built with
TypeScript94%
Updated yesterday
TypeScript
49%
AGPL 3.0

Grafana

Monitoring · Analytics

76,643

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
63
Dependency
Built with
TypeScript49%
Go45%
Updated today
TypeScript
97%
Other

GrowthBook

Developer Tools · Analytics · Monitoring

8,299

Open source feature flags, A/B testing, and warehouse-native experimentation that queries your existing data infrastructure—no data movement required.

View details
92
Repo Health
85
Technical
63
Dependency
Built with
TypeScript97%
Updated yesterday
Go
62%
Apache 2.0

Harness Open Source

Developer Tools · Devops · Code Editors

38,251

A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.

View details
89
Repo Health
79
Technical
64
Dependency
Built with
Go62%
TypeScript34%
Updated 3 days 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

Search