Socket
Socket
Sign inDemoInstall

@types/jsdom

Package Overview
Dependencies
5
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/jsdom

TypeScript definitions for jsdom


Version published
Maintainers
1
Weekly downloads
7,321,247
decreased by-4.37%

Weekly downloads

Package description

What is @types/jsdom?

The @types/jsdom package provides TypeScript type definitions for jsdom, a pure-JavaScript implementation of many web standards, notably the WHATWG DOM and HTML Standards. It allows for the simulation of a web browser's environment in Node.js, enabling the testing of web pages and applications without a browser. This package is essential for TypeScript developers working with jsdom, as it offers type checking and IntelliSense support in code editors.

What are @types/jsdom's main functionalities?

Creating a new JSDOM instance

This feature allows you to create a new JSDOM instance, simulating an HTML page. It is useful for testing and scraping web content in a Node.js environment.

import { JSDOM } from 'jsdom';
const dom = new JSDOM(`<html><body><p>Hello world</p></body></html>`);

Querying elements

After creating a JSDOM instance, you can query elements within the simulated page using standard DOM APIs, such as `querySelector`. This is particularly useful for testing DOM manipulation and event handling.

const paragraph = dom.window.document.querySelector('p');
console.log(paragraph.textContent); // Outputs: Hello world

Modifying elements

This feature demonstrates modifying the content of an element within the JSDOM instance. It's a common operation for testing dynamic web applications.

paragraph.textContent = 'Goodbye world';
console.log(dom.window.document.querySelector('p').textContent); // Outputs: Goodbye world

Other packages similar to @types/jsdom

Readme

Source

Installation

npm install --save @types/jsdom

Summary

This package contains type definitions for jsdom (https://github.com/jsdom/jsdom).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jsdom.

Additional Details

Credits

These definitions were written by Leonard Thieu, Johan Palmfjord, and ExE Boss.

FAQs

Last updated on 21 Nov 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc