agentleFS
NVIDIAKnown publisherNVIDIA/nvcf/src/uis/nvcf-ui/.agents/skills/testing/SKILL.md

testing

Skill268 starsChanged 3 days agoApache-2.0View on GitHub

Write frontend tests for the nvcf-ui app with Vitest, Testing Library, MSW, and the project's render helper. Use when creating test files, testing a page or component, mocking API responses, choosing how to render, or when a UI component is added or changed and tests have not been mentioned (tests are required). TypeScript and React only; Go backend tests follow standard Go practice.

194 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use bundle-dependency-prs, update-library-template and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MicrosoftSkill

    bundle-dependency-prs

    Fix broken dependency update PRs and aggregate the ones that work into one PR.

    Also in 7 projects that use this

  • MicrosoftSkill

    update-library-template

    Merges the latest Library.Template into this repo (at position of HEAD) and resolves conflicts.

    Also in 7 projects that use this

  • zetaloopSkill

    assign-copilot

    Assigns a GitHub issue to the Copilot coding agent, optionally specifying a custom agent. Use this when asked to assign an issue to Copilot or delegate an issue to CCA.

    Also in 3 projects that use this

  • NVIDIA-NeMoSkill

    build-and-dependency

    Dev environment setup for Megatron Bridge — container-based development, uv package management, lockfile regeneration, adding dependencies, Slurm container usage, and common build pitfalls.

    Also in 3 projects that use this

  • timmo001Skill

    changeset-scope

    Keep all scoped code work contained to the user-defined changeset. Use for implementation, fixes, diagnosis, refactoring, cleanup, and review when explicit instructions, named files, diffs, branches, pull requests, or injected work scopes define the boundary.

    Also in 3 projects that use this

  • JetBrainsSkill

    module-dependencies

    Add or modify IntelliJ module dependencies in `.iml` files.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 0 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 174 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never mock @tanstack/react-router.

    line 30
  2. Very specific:

    Never call setupServer in a test file.

    line 47
  3. Very specific:

    Prefer accessible queries (getByRole, getByText) over test IDs.

    line 66
  4. Very specific:

    Use userEvent over fireEvent.

    line 67
  5. Very specific:

    Use findBy queries or waitFor for async results.

    line 69

“Common” is measured: kept by at least 6 in 10 of the 174 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Testing

Adding or changing a component means adding or updating its tests.

How to render

TestingUseNotes
A page (route file)renderWithRouter({ initialLocation: "/functions" })Renders the app's generated route tree, so the real loader, search validation, and page run.
A component that uses router hooks but is not a routerenderWithRouter({ routeTree }) with a test-local treeBuild a small root and stub routes in the test. See AccountSwitcher.test.tsx.
A component that reads its own queries but uses no router hooksrenderWithQueryClient(<Component />)Mock its API calls with MSW. See InstanceTypesPanel.test.tsx.
A plain componentrender from @testing-library/reactPass data through props.
Pure logicA plain unit testNo rendering.
  • renderWithRouter and renderWithQueryClient live in ~/testing/render. Both create a fresh QueryClient; renderWithRouter also sets up memory history and router context.
  • Never mock @tanstack/react-router. Render a real router instead.
  • The helper sets only the router options tests assert on (today defaultErrorComponent). Add another option only when a test needs it.

Where tests live

  • Next to the file they test: FunctionCard.test.tsx beside FunctionCard.tsx. Never in a __tests__ folder.
  • Page tests sit beside their route file and are named after the page component: ui/src/routes/functions/FunctionDetail.test.tsx. Route generation ignores *.test.* files.

Mocking API responses

ui/vitest.setup.ts starts one MSW server backed by the seeded mock store and calls resetHandlers() after each test.

Never call setupServer in a test file. A local server replaces the global one, loses the store baseline, and fails on any endpoint you did not mock.

Layer overrides on top with server.use(...):

import { server } from "~/mocks/server";
import { handlers } from "~/mocks/scenarios/functions/empty-list";

beforeEach(() => {
  server.use(...handlers);
});

Scenario files export a handlers array. Reuse them instead of duplicating handler logic.

Guidelines

  • Prefer accessible queries (getByRole, getByText) over test IDs.
  • Use userEvent over fireEvent.
  • Cover the happy path, error state, and empty state.
  • Use findBy queries or waitFor for async results.
  • Assert user-visible behavior, not implementation details.

Validate

  1. Run task verify.
  2. Fix failures and rerun until clean.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.