NeoFaker Logo

NeoFaker

Hex.pm Version Hex.pm Downloads Elixir CI

NeoFaker generates realistic fake data for Elixir tests, database seeds, and local development.

Requirements

Installation

Add NeoFaker to your mix.exs dependencies:

def deps do
[
{:neo_faker, "~> 0.15.0", only: [:dev, :test]}
]
end

Then fetch it:

mix deps.get

See the Getting Started Guide for the full setup walkthrough, including test-suite configuration.

Configuration

Set a default locale in config/config.exs:

config :neo_faker, locale: :default

If the requested locale isn't available, NeoFaker falls back to :default (generic English (US) data). NeoFaker.Locale.set/1 changes the locale for the current process only. It's safe to use inside async: true tests, since it can't affect other tests running at the same time.

Using with Phoenix Framework

For a Phoenix app, set the locale in config/dev.exs and config/test.exs instead of the top-level config.exs. Then call NeoFaker.start() in test/test_helper.exs.

If you also use NeoFaker inside test/support/factory.ex to build fake Ecto.Schema structs for your tests, see the Ecto Test Factories guide. It covers wiring NeoFaker into the factory pattern from Ecto's own docs, and how to keep factory-generated values unique where your schema requires it.

Usage

iex> NeoFaker.Person.full_name()
"Abigail Bethany Crawford"
iex> NeoFaker.Internet.email()
"jose@example.com"
iex> NeoFaker.Address.city(locale: :id_id)
"Sigi"
iex> NeoFaker.Date.past(30)
~D[2025-02-25]
iex> NeoFaker.Color.hex()
"#613583"

Documentation

Contributing

Issues and pull requests are welcome on GitHub.

License

Licensed under the MIT License.