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

TypeScript
71%
Other

highlight.io

Analytics · Developer Tools · Monitoring

9,384

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
71
Repo Health
78
Technical
65
Dependency
Built with
TypeScript 71%
Go 16%
Updated 3 weeks ago
TypeScript
96%
MIT

HyperDX

Analytics · Developer Tools · Monitoring

9,939

Open source observability platform that unifies logs, traces, metrics, and session replays on ClickHouse — now the core of ClickStack.

View details
88
Repo Health
83
Technical
65
Dependency
Built with
TypeScript 96%
Updated 2 weeks ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Automation · Marketing

2,628

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
45
Repo Health
66
Technical
62
Dependency
Built with
TypeScript 94%
Updated 3 months ago
TypeScript
84%
MIT

LibreChat

AI Assistants · Developer Tools

45,474

Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.

View details
93
Repo Health
81
Technical
62
Dependency
Built with
TypeScript 84%
JavaScript 15%
Updated 2 weeks ago
Python
56%
MIT

LibrePhotos

File Storage

8,098

Self-hosted photo library with AI-powered face recognition, semantic search, and automatic event albums — no cloud required.

View details
84
Repo Health
78
Technical
66
Dependency
Built with
Python 56%
TypeScript 43%
Updated 1 weeks ago
Python
83%
MIT

LiteLLM

AI Development · Developer Tools

60,765

Open source AI gateway and Python SDK that gives you one OpenAI-compatible interface to call 100+ LLM providers, with built-in routing, cost tracking, guardrails, and virtual keys.

View details
93
Repo Health
81
Technical
69
Dependency
Built with
Python 83%
TypeScript 12%
Updated 1 weeks ago
TypeScript
97%
MPL 2.0

Logto

Authentication

14,663

Open-source auth infrastructure for SaaS and AI apps with OIDC, SAML, and RBAC

View details
92
Repo Health
83
Technical
63
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
TypeScript
52%
Other

Mattermost

Collaboration · Devops · Team Chat

39,306

Open core, self-hosted team collaboration with chat, AI agents, voice calling, and deep DevOps integrations — all under your control.

View details
96
Repo Health
87
Technical
65
Dependency
Built with
TypeScript 52%
Go 40%
Updated 2 weeks ago
Python
65%
Other

Onyx

AI Agents · AI Assistants · Knowledge Management

32,380

Self-hostable AI platform with agentic RAG, 50+ connectors, deep research, code execution, and support for every major LLM provider.

View details
92
Repo Health
83
Technical
68
Dependency
Built with
Python 65%
TypeScript 25%
Updated 1 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