AI Analysis
Mox is a library for creating concurrent mocks in Elixir based on explicit behavior contracts. It enables concurrent testing with async support while following principled mocking practices that emphasize pattern matching and function clauses over complex expectation rules.
Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.
AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.
Mox: Elixir's structured mock library enforcing contracts through behaviours and concurrency
Mox is a testing library for Elixir that provides concurrent mocks based on behaviour contracts, rather than ad-hoc dynamic mocking. It enforces a testing philosophy emphasizing explicit contracts, pattern matching, and async-safe test isolation. Created by Dashbit and actively maintained, it appears to be the standard mock library for Elixir projects that follow strict testing disciplines. Adoption is embedded within the Elixir ecosystem rather than universally known.
Mox originated in 2017 from Plataformatec (later Dashbit) as a response to testing philosophy concerns documented in the 'Mocks and explicit contracts' blog post. It formalizes contract-driven testing for Elixir's concurrent model. Ownership transitioned to Dashbit, which has maintained steady development and documentation.
Growth has been moderate and stable rather than explosive. The 1,396 stars reflect acceptance within the Elixir community but modest absolute visibility. Recent activity (last push 2026-05-06, only 1 star in last 7 days) suggests maturity plateau: the library has reached its intended audience and continues steady maintenance rather than pursuing viral adoption. Growth appears driven by Elixir adoption trends and word-of-mouth within the community rather than marketing or major features.
Adoption not verified in provided metadata. No case studies, testimonials, or company usage lists appear in README. The library is distributed via hex.pm (Elixir's package manager) and appears to be the de facto standard in Elixir testing tutorials and community discourse, but concrete production adoption metrics are absent. Presence on hex.pm and in CI workflows suggests real usage, but scale is unquantified.
Based on README, Mox follows a behaviour-driven design: mocks must be defined against Elixir behaviours (interfaces), preventing ad-hoc mocking. Likely uses Elixir's module system and concurrency primitives (processes) to isolate mock state per test, enabling `async: true` test modes. The library appears to leverage pattern matching and function clauses rather than complex expectation DSLs.
README shows CI badge and coverage badge (Coveralls), indicating active test coverage tracking. Specific coverage percentage not documented in provided excerpt, but presence of both signals suggests reasonable coverage discipline.
Last push 2026-05-06 (55 days before evaluation date) indicates active maintenance. CI workflows present and apparently passing. No recent abandonment signals. Release cadence not explicitly stated in README, but steady maintenance over 9 years (created 2017) with no long gaps suggests committed long-term stewardship. Growth in stars per week (1 in last 7 days) is low but consistent with a mature, stable library that has found its niche.
ADOPT IF: you are building Elixir applications that require async-safe, contract-enforced mocking and value explicit testing philosophy. AVOID IF: you need mocking for languages outside Elixir, or if your team prefers ad-hoc/flexible mock generation without strict behaviour contracts. MONITOR IF: you are evaluating Elixir testing frameworks for the first time—Mox is the structured choice, but simpler ad-hoc stubbing may suffice for smaller projects.
Independent dimensions
Mainstream potential
3/10
Technical importance
7/10
Adoption evidence
4/10
- Adoption limited to Elixir ecosystem; no value outside that language.
- Requires architectural discipline: projects must define behaviours before writing implementations, raising onboarding friction for teams unfamiliar with contract-driven design.
- Philosophy-dependent adoption: teams rejecting the 'no ad-hoc mocks' principle will see no benefit and may face friction.
- Ecosystem concentration risk: active maintenance dependent on Dashbit's continued stewardship; no evident community of co-maintainers.
- Growth plateau suggests limited expansion beyond Elixir core—unlikely to broaden audience unless Elixir adoption accelerates significantly.
Mox will likely remain the standard mock library for Elixir projects that prioritize testing discipline and concurrency safety. Adoption growth will track Elixir ecosystem growth, not outpace it. Maintenance will continue at steady, low-churn rate suitable for a mature library. No major feature expansion expected unless Elixir language changes demand it.
Explore similar
Newsletter
Get analyses like this every Monday
Free weekly digest of the most interesting open-source discoveries.
Languages
Information
- Language
- Elixir
- Last updated
- 2mo ago
- Created
- 107mo ago
- Analyzed with
- anthropic/claude-haiku-4-5
Stars over time
Contributors over time
Top 100 contributors only — repos with more will plateau at 100.
Open issues
`verify_on_exit!/1` breaks Ecto Sandbox transaction rollback in shared mode (async: false tests)
Timing issue after using `set_mox_global`
Support for @macrocallback ?
Confusing error message when test finishes before expectation is called
Multiple expectations that can happen in every order
Top contributors
Recent releases
No releases published yet.
Similar repos
beam-community/ex_machina
ExMachina is a factory library for Elixir that simplifies test data creation...
| Repository | Stars | Week Δ | Language | Score | Updated |
|---|---|---|---|---|---|
|
|
1.4k | — | Elixir | 9/10 | 2mo ago |
|
|
2.1k | — | Elixir | 8/10 | 3w ago |
|
|
5.7k | — | Kotlin | 8/10 | 4w ago |
|
|
8.3k | — | TypeScript | 8/10 | 4d ago |
|
|
1.2k | — | Elixir | 8/10 | 3mo ago |
ex_machina (2050 stars) is a factory/fixture library complementary to Mox, not a direct competitor. Serves data generation; Mox serves mock behavior. Often used together in Elixir projects.
mockk (5744 stars, Kotlin) is a mocking library for the JVM ecosystem. Operates in a different language/runtime; not a practical alternative for Elixir projects.
Hammox (mentioned in README) is an enhanced fork that adds automatic typespec validation. It extends rather than replaces Mox, indicating Mox is the foundational tool and Hammox is optional enhancement.
ExUnit (Elixir's built-in test framework) allows manual stubbing/mocking. Mox provides structured, contract-enforced alternative; many Elixir projects likely use ExUnit's ad-hoc approach rather than Mox, suggesting Mox adoption is deliberate rather than default.
Some Elixir projects use GenServer agents or process-based test doubles without Mox. Mox abstracts and standardizes this pattern, but alternative approaches exist and may be preferred for simpler scenarios.