expect-element is an extension for the expect assertion library that provides DOM-specific assertions for testing DOM nodes. Current stable version is 1.1.1, released under the MIT license. It adds assertions like toHaveAttribute, toHaveText, etc. This package is lightweight, requires expect as a peer dependency, and is designed for unit testing in browser or jsdom environments. It is not actively maintained (last release in 2016). Compared to alternatives like jest-dom, expect-element is simpler but lacks TypeScript support and modern updates.
npm install expect-elementNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic setup and usage of expect-element with DOM assertions.
Consider using jest-dom or @testing-library/jest-dom for modern DOM assertions.
import expectElement from 'expect-element'; expect.extend(expectElement);
Ensure expect@^1.15.1 is installed.
npm install expect expect-element
import expectElement from 'expect-element'; expect.extend(expectElement);