# jest-hooks-dom

> Jest hooks for DOM

Latest version **0.1.0** (published 2020-05-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install jest-hooks-dom
pnpm add jest-hooks-dom
yarn add jest-hooks-dom
bun add jest-hooks-dom
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-05-11 |
| First published | 2020-05-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 38.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Boris Kaul |
| Maintainers | localvoid |

## Links

- npm: https://www.npmjs.com/package/jest-hooks-dom
- Repository: https://github.com/localvoid/jest-hooks
- Issues: https://github.com/localvoid/jest-hooks/issues
- npm.io page: https://npm.io/package/jest-hooks-dom

## Recent versions

- 0.1.0 (latest) — 2020-05-11

## README

<p align="center">
  <img width="507" height="351" src="https://localvoid.github.io/jest-hooks-dom/example.png">
</p>

`jest-hooks-dom` is a collection of [hooks](https://github.com/localvoid/jest-hooks) for DOM testing with
[Jest](https://jestjs.io/) library.

## Hooks

### Elements

`useHTMLElement(element, container)` creates a new HTML element before each test and optionally mounts it to the
container. After each test HTML element is removed from any container.

`useSVGElement(element, container)` creates a new SVG element.

### Mutation Tracking

`useDOMMutationTracker()` tracks DOM mutations.

Methods and properties tracked:

 - `Document.prototype.createElement`
 - `Document.prototype.createElementNS`
 - `Document.prototype.createTextNode`
 - `Node.prototype.appendChild`
 - `Node.prototype.insertBefore`
 - `Node.prototype.replaceChild`
 - `Node.prototype.removeChild`
 - `Node.prototype.textContent`
 - `Node.prototype.nodeValue`
 - `Element.prototype.innerHTML`

### Events

`useResetDOMEventListeners()` tracks all unregistered event listeners and automatically removes them after each test.

### requestAnimationFrame

`useRequestAnimationFrame()` mocks `requestAnimationFrame()` and `cancelAnimationFrame()`, and resets all tasks after
each test.

---
_Source: https://npm.io/package/jest-hooks-dom · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
