fxa-test-draft

Drafts Jest tests for changed code in the Mozilla Accounts monorepo following FXA conventions.

685|236|Updated Jun 3, 2015
One-click install
npx skills add https://github.com/mozilla/fxa --skill fxa-test-draft
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fxa-test-draft
Source: https://github.com/mozilla/fxa/tree/main/.claude/skills/fxa-test-draft
Command: npx skills add https://github.com/mozilla/fxa --skill fxa-test-draft

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing tests for new or modified code is repetitive and requires deep knowledge of each package's conventions. This Skill analyzes your git changes and drafts Jest tests that follow FXA testing rules, giving you a reviewed starting point instead of a blank file.

Core Features & Use Cases

  • Automatic Scope Detection: Targets staged/unstaged changes by default, or accepts a file path, commit ref, or git range as an argument.
  • Convention-Aware Drafting: Explores existing test files, shared mocks (mockDB, mockLog, mockMailer), and jest.mock patterns in each package before writing tests.
  • Review-First Workflow: Presents a test plan table covering happy paths, error cases, edge cases, and branches, then pauses for your confirmation before drafting.
  • Use Case: After modifying an account route handler in fxa-auth-server, run the Skill to get draft spec tests covering success, NotFound errors, and boundary conditions, plus callouts for hard-to-test code.

Quick Start

Ask the assistant to draft Jest tests for your current uncommitted changes, or specify a file path or commit range to target.

Frequently Asked Questions about fxa-test-draft

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

FAQPage Schema
How do I generate Jest tests for my git changes?

Run the Skill with no arguments to target staged and unstaged changes, or pass a file path, commit ref, or git range. It reads the diff, identifies testable logic, and drafts Jest tests after you approve a coverage plan.

What testing framework does the fxa monorepo use?

The fxa monorepo uses Jest for all new tests. The Skill flags any Mocha usage as legacy and will not draft new Mocha tests, following the FXA testing guidelines.

Does it support React component tests in fxa-settings?

Yes. When changed files are React/TSX, the Skill loads the React testing rules and drafts component tests using the package's conventions, such as provider wrapping with Intl and Router.

Where are the drafted tests placed?

Tests go in co-located files following package conventions: *.spec.ts in fxa-auth-server lib/ directories and *.test.tsx next to components in fxa-settings. New files include the MPL-2.0 license header.

Are the generated tests ready to commit?

No, the output is explicitly a draft. You should review mock return values, error types, and edge case assumptions before committing, and the Skill pauses for plan approval before writing any test code.