From elixir-phoenix
Provides Elixir testing patterns for ExUnit, Mox mocks, factories, and LiveView helpers. Use on *_test.exs files, test/support/, factories, or fixing test failures.
How this skill is triggered — by the user, by Claude, or both
Slash command
/elixir-phoenix:testingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Quick reference for Elixir testing patterns.
Quick reference for Elixir testing patterns.
async: true unless tests modify global state@callback behaviourbuild/2 in factories; insert/2 only when DB neededassert_receive with timeout for async operationsvalidate_required in the schema changeset. Missing fields cause cascading test failures| Testing | Use |
|---|---|
| Controller/API | use MyAppWeb.ConnCase |
| Context/Schema | use MyApp.DataCase |
| LiveView | use MyAppWeb.ConnCase + import Phoenix.LiveViewTest |
| Pure logic | use ExUnit.Case, async: true |
Application.put_envbuild() by default for speedinsert() only when you need DB ID, constraints, or persisted associations# Setup chain
setup [:create_user, :authenticate]
# Pattern matching assertion
assert {:ok, %User{name: name}} = create_user(attrs)
# Async message assertion
assert_receive {:user_created, _}, 5000
# Mox setup
setup :verify_on_exit!
expect(MockAPI, :call, fn _ -> {:ok, "data"} end)
# LiveView async
html = render_async(view) # MUST call for assign_async
| Wrong | Right |
|---|---|
Process.sleep(100) | assert_receive {:done, _}, 5000 |
insert(:user) in factory | build(:user) in factory |
async: true with set_mox_global() | async: false |
| Mock internal modules | Test through public API |
For detailed patterns, see:
${CLAUDE_SKILL_DIR}/references/exunit-patterns.md - Setup, assertions, tags${CLAUDE_SKILL_DIR}/references/mox-patterns.md - Behaviours, expect/stub, async${CLAUDE_SKILL_DIR}/references/liveview-testing.md - Forms, async, uploads${CLAUDE_SKILL_DIR}/references/factory-patterns.md - ExMachina, sequences, traitsnpx claudepluginhub oliver-kriska/claude-elixir-phoenix --plugin elixir-phoenixGuides Elixir testing with ExUnit: unit/integration/property-based tests, assertions, mocks, fixtures, tags, describe blocks, setup, and concurrent code testing.
Guides Elixir testing with ExUnit: writing unit tests, organizing test suites, using assertions, setup/teardown, and test tags.
Guides Phoenix Elixir test writing with TDD workflow, fixtures, DataCase/ConnCase setups, describe blocks, happy/error paths, LiveView assertions. For _test.exs files.