testing-essentials

A set of rules for writing ExUnit tests, Elixir's testing framework, including tests for Phoenix LiveView pages. It also describes TDD, or test-driven development: write a failing test first, then add the code that makes it pass.

In plain words
What is it for?
Use it when writing or repairing ExUnit tests, preparing fixtures, checking LiveView page structure, testing public application interfaces, or following a test-first workflow.
Why use it?
It helps tests cover successful, invalid, and unauthorized cases while following the project's existing setup instead of duplicating boilerplate.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/j-morgan6/elixir-phoenix-guide/testing-essentials
Any agent
npx skills add j-morgan6/elixir-phoenix-guide --skill testing-essentials
Clone the repo
git clone --depth 1 https://github.com/j-morgan6/elixir-phoenix-guide

Made for: Claude Code, Codex.

Per session 31 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,464 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00031 $0.01464
Opus 5 $0.00015 $0.00732
Sonnet 5 $0.00006 $0.00293
Haiku 4.5 $0.00003 $0.00146

Measured 2d ago against content hash 2577f3602509, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing-essentials scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/testing-essentials/SKILL.md · 209 lines

How it starts

The opening of the file, as written. The whole thing — 209 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Testing Essentials

RULES — Follow these with no exceptions

  1. Follow the project's existing test setup patterns (e.g. shared setup helpers like setup :store_test_session) — don't inline DataCase/ConnCase boilerplate that the project already abstracts away
  2. Test both happy path AND error/invalid cases for every function
  3. Use async: true by default; disable it only for real shared state — global state, Application.put_env, named processes, external services. LiveView/ConnCase tests are async-safe under the Ecto SQL Sandbox (Phoenix's own generators emit async: true).
  4. Define test data in fixtures (test/support/) — never build it inline across multiple tests
  5. Use has_element?/2 and element/2 for LiveView assertions — not html =~ "text" for structure checks
  6. Always test the unauthorized case for any protected resource
  7. Test the public context interface, not internal implementation details
  8. Use describe blocks to group tests by function or behavior

TDD Workflow

Write the failing test first. Run it to confirm it fails for the right reason. Implement the minimum code to make it pass. Never write implementation before the test exists.

mix test test/my_app/accounts_test.exs  # Should fail first
# ... implement ...
mix test test/my_app/accounts_test.exs  # Should pass

Test Module Setup

DataCase — for context and schema tests

defmodule MyApp.AccountsTest do
  use MyApp.DataCase, async: true

  alias MyApp.Accounts
  import MyApp.AccountsFixtures
end

ConnCase — for LiveView and controller tests

defmodule MyAppWeb.UserLiveTest do
  use MyAppWeb.ConnCase, async: true

  import Phoenix.LiveViewTest
  import MyApp.AccountsFixtures
end

Fixture Pattern

Define all test data in test/support/fixtures/:

defmodule MyApp.AccountsFixtures do
  def user_fixture(attrs \\ %{}) do
    {:ok, user} =
      attrs
      |> Enum.into(%{
        email: "user#{System.unique_integer([:positive])}@example.com",
        password: "hello world!"
      })
      |> MyApp.Accounts.register_user()

    user
  end
end

Read the full file on GitHub · 209 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 209 lines · 31 tokens per session scan A 2577f3602509

Subscribe to this mod's changes

testing-essentials is a skill published in the GitHub repository j-morgan6/elixir-phoenix-guide (156 stars, last pushed 1mo ago), licensed MIT. It adds 31 tokens to every session and 1,464 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.