jest-hooks-dom
v0.1.0
Published
Jest hooks for DOM
Downloads
2
Readme
jest-hooks-dom
is a collection of hooks for DOM testing with
Jest 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.