Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@testing-library/dom

Package Overview
Dependencies
Maintainers
12
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@testing-library/dom

Simple and complete DOM testing utilities that encourage good testing practices.

  • 6.14.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16M
decreased by-5.11%
Maintainers
12
Weekly downloads
 
Created

What is @testing-library/dom?

The @testing-library/dom package is a lightweight solution for testing DOM nodes (whether they are part of a web browser environment or not) in a way that simulates user actions. It aims to test the functionality of components in a user-centric manner. This library is part of the larger Testing Library ecosystem, which provides tools and utilities to work with React, Vue, Angular, and other frameworks by extending the base functionality provided in @testing-library/dom.

What are @testing-library/dom's main functionalities?

Querying DOM Elements

Allows querying DOM elements using text content, which simulates how users find elements on the page. This is useful for ensuring elements are present and contain the correct content.

const { getByText } = require('@testing-library/dom');
const element = getByText(document.body, 'Hello World');

Firing Events

Simulates user actions by firing events on DOM elements. This is crucial for testing interactive elements like buttons and forms.

const { fireEvent } = require('@testing-library/dom');
fireEvent.click(document.querySelector('button'));

Waiting for Elements

Provides utilities to wait for elements to appear or change, which is useful for testing asynchronous behavior like data fetching or animations.

const { waitFor } = require('@testing-library/dom');
await waitFor(() => getByText(document.body, 'Loaded'));

Other packages similar to @testing-library/dom

Keywords

FAQs

Package last updated on 04 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc