Answer: Write each test file with a name ending in `.test.ts`, import the test kit from `claude-code/testing`, and run tests from your shell with `claude plugin test`. Each test file needs at least one `test()`, and you use stubs registered with `on` to answer what Claude Code would answer. Status: Confirmed Entry: tool/claude-code/agents-and-automation/write-mod-test Revision: 3 Digest: sha256:9569d3537c12e1d9 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:05:18Z Last changed: 2026-11-18T12:19:05Z (Check succeeded again) Last verified: 2026-11-20T12:23:52Z Next check: 2026-11-21T12:23:52Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of test command | claude plugin test | [1] | 2026-11-20 test file naming | .test.ts | [1] | 2026-11-20 test kit import | claude-code/testing | [1] | 2026-11-20 minimum tests per file | at least one `test()` | [1] | 2026-11-20 failure exit status | status 1 | [1] | 2026-11-20 example test file path | first-mod/tests/first-mod.test.ts | [1] | 2026-11-20 Sources: [1] Anthropic. "Test a mod". https://code.claude.com/docs/en/plugins/mods/test.md Role: primary. Accessed: 2026-11-20T12:23:52Z Quote: "You run tests from your shell with `claude plugin test`" (Supports: test command) Quote: "Give each test file a name that ends in `.test.ts`" (Supports: test file naming) Quote: "each test file imports the test kit, a test library in the `claude-code/testing` module" (Supports: test kit import) Quote: "Every test file needs at least one `test()`, or the run fails with `declares no test(): nothing ran`" (Supports: minimum tests per file) Quote: "The command exits with status 1 when a test fails, so it works in CI." (Supports: failure exit status) Quote: "Save it as `first-mod/tests/first-mod.test.ts`" (Supports: example test file path) Published: 2026-11-20T03:41:00Z Snapshot SHA-256: ecd103b6b851eaaf887c3b26c34f4cfdb9d547bcbe6d8b2df147bd32c788bd5e (captured 2026-11-17T12:29:40Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-18T12:19:05Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T12:23:52Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:23:52Z Last attempt: 2026-11-20T12:23:52Z Notes and limitations: Extracted automatically from a single official source (section "Write a test"). Related: https://latestn.com/tool/claude-code/agents-and-automation/zod-pydantic-schemas How do I define a type-safe schema with Zod or Pydantic for Claude Code structured outputs? https://latestn.com/tool/claude-code/commands-and-shortcuts/available-actions-contexts Which keyboard shortcut contexts and actions are available in Claude Code? https://latestn.com/tool/claude-code/commands-and-shortcuts/chain-multiple-skills How do I chain multiple skills in one message in Claude Code? https://latestn.com/tool/claude-code/agents-and-automation/what-is-a-subagent What is a subagent in Claude Code? https://latestn.com/tool/claude-code/agents-and-automation/when-to-use-single-message-input When should I use single message input instead of streaming input in the Claude Agent SDK? https://latestn.com/tool/claude-code/agents-and-automation/write-eval-case How do I write an eval case for a Claude Code plugin, including prompt.md frontmatter and case.yaml fields? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-18T12:19:05Z | recovered | Check succeeded again | — 2026-11-18T12:19:05Z | changed | example test file path: — → first-mod/tests/first-mod.test.ts | [1] 2026-11-18T12:19:05Z | changed | mock.session version requirement: v2.1.293 → — | [1] 2026-11-17T12:29:39Z | check-failed | Extraction did not pass verification: answer contains ` to fire events through your mod's hooks and `, which does not appear in the source | — 2026-11-15T12:24:07Z | changed | mock.session version requirement: — → v2.1.293 | [1] 2026-11-15T12:24:07Z | changed | example test file path: first-mod/tests/first-mod.test.ts → — | [1] 2026-11-13T03:05:18Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/agents-and-automation/write-mod-test/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/agents-and-automation/write-mod-test POST: https://latestn.com/dispute/tool/claude-code/agents-and-automation/write-mod-test with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/agents-and-automation/write-mod-test?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I write an automated test for a Claude Code mod? Revision 3, last verified 2026-11-20T12:23:52Z. https://latestn.com/tool/claude-code/agents-and-automation/write-mod-test (accessed 2026-11-21T10:00:32Z). @misc{LatestN_tool_claude_code_agents_and_automation_write_mod_test_r3, title = {How do I write an automated test for a Claude Code mod?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/agents-and-automation/write-mod-test}}, note = {Revision 3; digest sha256:9569d3537c12e1d9; last verified 2026-11-20T12:23:52Z; accessed 2026-11-21T10:00:32Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/agents-and-automation/write-mod-test