{
 "kind": "tool",
 "slug": "testing-library",
 "path": "tools/testing-library/",
 "name": "Testing Library",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Testing",
   "tools/testing/"
  ]
 ],
 "lead": "Testing utilities for React encouraging testing user behavior.",
 "chips": [
  {
   "label": "Testing",
   "path": "tools/testing/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install @testing-library/react"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/testing-library/react-testing-library"
  },
  {
   "label": "Website",
   "href": "https://github.com/testing-library/react-testing-library#readme"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from npm.",
   "src": "https://github.com/testing-library/react-testing-library"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Aug 27, 2026",
   "note": "Latest GitHub release Aug 27, 2026. ",
   "src": "https://github.com/testing-library/react-testing-library"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "640 projects",
   "status": "info",
   "sub": "#3 of 122 in its category",
   "note": "Dependency in 640 public GitHub projects set up for AI coding agents that we scanned (10.2%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Community skills",
   "status": "info",
   "sub": "6 skills by others",
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What Testing Library does",
   "parts": [
    {
     "t": "prose",
     "text": "React Testing Library gives you no supported way into component instances: tests work on real DOM nodes and find elements by label, text or role, as a user would."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "Testing Library popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "83",
       "of": "/ 100",
       "l": "Gid Score, #53 overall"
      },
      {
       "n": "101M",
       "l": "downloads a week, npm"
      },
      {
       "n": "19.7K",
       "l": "GitHub stars"
      },
      {
       "n": "640",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How Testing Library is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "Testing Library is a dependency in 640 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (13.1% of the 4,867 JavaScript/TypeScript ones), #3 of 122 in testing.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,483; those are left out of every share on this page.",
      "The most used alternative in our scan is Vitest (1,312 projects).",
      "Projects that use it most often also use Vitest (74.1%), jsdom (64.8%), React (90.0%).",
      "It is more common in projects set up for Devin Desktop (16.8%) than for GitHub Copilot (9.0%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "391 projects, 11.9%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "331 projects, 13.6%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "273 projects, 9.0%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "71 projects, 15.1%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "68 projects, 14.3%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "47 projects, 16.8%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "40 projects, 11.7%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "23 projects, 16.4%",
       "v": "Kiro",
       "path": "agents/kiro/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 74.1% of its projects",
       "v": "Vitest",
       "path": "tools/vitest/"
      },
      {
       "l": "In 64.8% of its projects",
       "v": "jsdom",
       "path": "tools/jsdom/"
      },
      {
       "l": "In 90.0% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 65.9% of its projects",
       "v": "Vite",
       "path": "tools/vite/"
      },
      {
       "l": "In 74.5% of its projects",
       "v": "Tailwind CSS",
       "path": "tools/tailwindcss/"
      },
      {
       "l": "In 57.8% of its projects",
       "v": "Lucide React",
       "path": "tools/lucide-react/"
      },
      {
       "l": "In 78.0% of its projects",
       "v": "ESLint",
       "path": "tools/eslint/"
      },
      {
       "l": "In 94.5% of its projects",
       "v": "TypeScript",
       "path": "tools/typescript/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "Testing Library in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Queries match how users find things",
       "v": "The site says the utilities support querying the DOM \"in the same way the user would\". Form fields are found by their label text. Links and buttons are found by their text."
      },
      {
       "l": "Refactors are not supposed to break tests",
       "v": "The README states this goal directly. A refactor changes the implementation but not the behavior, and it should leave the tests passing."
      },
      {
       "l": "Hooks or classes, same test",
       "v": "A comment in the README's basic example says the library works with both component styles. It also says your tests stay the same however the component is written."
      },
      {
       "l": "A sanctioned escape hatch",
       "v": "Some elements have no useful text or label. For those, the site points to a recommended <code>data-testid</code> query, so you do not have to invent your own selectors."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "You still need a test runner",
       "v": "The site says plainly that this is not a test runner or framework. Something else has to run the tests and provide <code>expect</code>. Jest is the maintainers' preference, but the site says any framework works."
      },
      {
       "l": "A second package to install since v16",
       "v": "From RTL version 16, <code>@testing-library/dom</code> is a peer dependency. You install it yourself next to <code>@testing-library/react</code>."
      },
      {
       "l": "React 18 needed from v13",
       "v": "The README says versions 13 and up require React v18. Projects on older React should install version 12."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Toggle a checkbox, check the message appears"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Jsx",
       "code": "// __tests__/hidden-message.js\n// these imports are something you'd normally configure Jest to import for you\n// automatically. Learn more in the setup docs: https://testing-library.com/docs/react-testing-library/setup#cleanup\nimport '@testing-library/jest-dom'\n// NOTE: jest-dom adds handy assertions to Jest and is recommended, but not required\n\nimport * as React from 'react'\nimport {render, fireEvent, screen} from '@testing-library/react'\nimport HiddenMessage from '../hidden-message'\n\ntest('shows the children when the checkbox is checked', () => {\n  const testMessage = 'Test Message'\n  render(<HiddenMessage>{testMessage}</HiddenMessage>)\n\n  // query* functions will return the element or null if it cannot be found\n  // get* functions will return the element or throw an error if it cannot be found\n  expect(screen.queryByText(testMessage)).toBeNull()\n\n  // the queries can accept a regex to make your selectors more resilient to content tweaks and changes.\n  fireEvent.click(screen.getByLabelText(/show/i))\n\n  // .toBeInTheDocument() is an assertion that comes from jest-dom\n  // otherwise you could use .toBeDefined()\n  expect(screen.getByText(testMessage)).toBeInTheDocument()\n})"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about Testing Library",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Agent Skills for it",
       "path": "skills/",
       "items": [
        "react-modernization: Upgrade React applications to latest versions, migrate from class components to hooks, and adopt concurrent features. Use when modernizing R",
        "react-native-dev: React Native and Expo development guide covering components, styling, animations, navigation, state management, forms, networking, performan",
        "react-expert: Use when building React 18+ applications in .jsx or .tsx files, Next.js App Router projects, or create-react-app setups. Creates components,",
        "react-vite-dashboard: Convert Stitch designs into production React + Vite dashboards with TanStack Query, accessible tokens from DESIGN.md, and Web3-ready pattern",
        "react-composition-patterns: React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component librarie",
        "react-hook-form: React Hook Form performance optimization for client-side form validation using useForm, useWatch, useController, useFieldArray, the subscrib"
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "@testing-library/jest-dom: Custom DOM matchers for expect",
        "@testing-library/user-event: Simulated user interactions",
        "@testing-library/dom: Core queries, required peer",
        "@testing-library/react-native: React Native variant",
        "@testing-library/jest-native: Matchers for React Native",
        "@testing-library/svelte: Svelte variant"
       ]
      },
      {
       "title": "More in Testing",
       "path": "tools/testing/",
       "items": [
        {
         "text": "Playwright (JavaScript)",
         "path": "tools/playwright-test/"
        },
        {
         "text": "jsdom",
         "path": "tools/jsdom/"
        },
        {
         "text": "pytest",
         "path": "tools/pytest/"
        },
        {
         "text": "Happy DOM",
         "path": "tools/happy-dom/"
        },
        {
         "text": "axe-core Playwright",
         "path": "tools/axe-core-playwright/"
        },
        {
         "text": "SuperTest",
         "path": "tools/supertest/"
        },
        {
         "text": "Mock Service Worker",
         "path": "tools/msw/"
        },
        {
         "text": "Faker.js",
         "path": "tools/faker-js-faker/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "Testing Library",
       "me": true,
       "facts": [
        "MIT",
        "Gid 83",
        "101M/wk"
       ]
      },
      {
       "name": "Vitest",
       "why": "Next-generation testing framework powered by Vite with native ESM.",
       "path": "tools/vitest/",
       "facts": [
        "MIT",
        "Gid 86",
        "194M/wk"
       ]
      },
      {
       "name": "Jest",
       "why": "Delightful JavaScript testing framework with minimal configuration.",
       "path": "tools/jest/",
       "facts": [
        "MIT",
        "Gid 86",
        "63.2M/wk"
       ]
      }
     ],
     "more": "Compare Testing Library with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "npm install @testing-library/react"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## React Testing Library\n- Install as a devDependency together with `@testing-library/dom` (required from v16): `npm install --save-dev @testing-library/react @testing-library/dom`. For TypeScript, add `@types/react` and `@types/react-dom`.\n- If the project uses React older than 18, install `@testing-library/react@12`. Versions 13+ require React v18.\n- Find elements the way a user would, by label text or visible text. Use `data-testid` only as an escape hatch when text and labels do not make sense.\n- Use `queryBy*` to assert absence, because it returns `null`. Use `getBy*` when the element must exist, because it throws if it is not found. For UI that appears later, await a `findBy*` query, as the README's login example does with `await screen.findByRole('alert')`.\n- Work with DOM nodes, not component instances. Keep implementation details out of assertions.\n- Mock API calls with Mock Service Worker instead of stubbing `window.fetch`, as the README recommends.\n- Test single-use custom hooks through the component that uses them, not in isolation.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm @testing-library/react"
  ],
  [
   "Category",
   "Testing"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "v16.3.3, August 27, 2026"
  ],
  [
   "On GitHub since",
   "March 2018"
  ],
  [
   "Gid Score",
   "83.3"
  ],
  [
   "Rank in category",
   "#3 of 122"
  ],
  [
   "GitHub",
   "testing-library/react-testing-library"
  ],
  [
   "Last change",
   "Aug 27, 2026"
  ]
 ],
 "good": [],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/testing-library.png"
}