writing-tests

Guides writing, placing, and running Elixir, API, feature, and JS tests in the Operately codebase.

553|70|Updated Feb 28, 2023
One-click install
npx skills add https://github.com/operately/operately --skill writing-tests-operately
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: writing-tests
Source: https://github.com/operately/operately/tree/main/.agents/skills/writing-tests
Command: npx skills add https://github.com/operately/operately --skill writing-tests-operately

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers working in the Operately repository often struggle to know where a new test file belongs, which case module to use, and how to run only the relevant tests without triggering slow full-suite runs. This Skill encodes the repository's test layout conventions, naming rules, and execution commands so tests are created and run correctly the first time. ## Core Features & Use Cases - Test placement rules: Maps source files to test locations via .projections.json conventions, enforcing one test module per API endpoint and steps modules for feature, CLI, and MCP e2e tests. - Case modules and patterns: Documents when to use DataCase, TurboCase, ConnCase, FeatureCase, the Factory pattern, feature step modules, and email assertions. - External API auth specs: Explains how to add QuerySpec/MutationSpec modules, register them in queries.ex/mutations.ex, and validate token auth via auth_test.exs. - Targeted test execution: Shows how to run single files with make test FILE=..., run feature tests in CI mode with CI=true, and avoid slow suite-wide commands. - Use Case: When adding a new documents/list_versions API endpoint, use this Skill to create the matching TurboCase test, add an external QuerySpec, register it, and run only the affected test files. ## Quick Start Ask the agent to write and run a test for a specific Operately module or API endpoint following the repository's testing conventions.

Frequently Asked Questions about writing-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a single Elixir test file in the Operately repo?▼

Run a single test file with `make test FILE=app/test/path/to/file_test.exs` from the repo root, optionally appending `:line_number` for one test. Avoid bare `make test` or suite-wide targets, which run the entire suite and are slow.

Where should a new API endpoint test go in an Elixir Phoenix project?▼

Each API endpoint module gets exactly one test module mirroring its path: `app/lib/operately_web/api/documents/list_versions.ex` maps to `app/test/operately_web/api/documents/list_versions_test.exs`. Do not bundle multiple endpoints into one shared test file.

How do I write feature tests with Wallaby in Operately?▼

Feature tests use `Operately.FeatureCase` and chain steps from a matching steps module under `app/test/support/features/`. For CI-equivalent runs, build assets with `make test.build` and run with `CI=true` inside `./devenv` so Wallaby does not depend on a local Vite server.

What is required when adding an external API endpoint with token auth?▼

Besides the normal TurboCase test, add a QuerySpec or MutationSpec module with `setup/1`, `inputs/1`, and `assert/2`, register it in `queries.ex` or `mutations.ex`, then run the matching `auth_test.exs` to verify token behavior and coverage.

Why does my feature test show a blank page locally?▼

Local non-CI feature tests expect Vite on localhost:4005; without it Wallaby loads a blank page. Either start Vite or run the test with `CI=true` through `./devenv` after `make test.build`.

Should new tests use fixtures or the Factory pattern?▼

New tests should prefer `Operately.Support.Factory`, which wires related entities correctly via calls like `Factory.setup()` and `Factory.add_project/3`. Hand-rolled fixture calls are discouraged, though older tests may still use them.