# @nichoth/test-dom

> Tools for testing in a browser environment

Latest version **0.6.4** (published 2023-05-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install @nichoth/test-dom
pnpm add @nichoth/test-dom
yarn add @nichoth/test-dom
bun add @nichoth/test-dom
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.6.4 |
| Published | 2023-05-16 |
| First published | 2022-12-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 30.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | nichoth |
| Keywords | dom, test |

## Links

- npm: https://www.npmjs.com/package/@nichoth/test-dom
- Repository: https://github.com/nichoth/test-dom
- Homepage: https://github.com/nichoth/test-dom#readme
- Issues: https://github.com/nichoth/test-dom/issues
- npm.io page: https://npm.io/package/@nichoth/test-dom

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 0.6.4 (latest) — 2023-05-16
- 0.6.3 — 2022-12-23
- 0.6.2 — 2022-12-23
- 0.6.1 — 2022-12-23
- 0.6.0 — 2022-12-23

## README

# test dom
Tools for interacting with DOM elements

## install

```
npm i -D @nichoth/test-dom
```

## use

### commonjs
```js
const dom = require('@nichoth/test-dom')
```

### esm
```js
import { dom } from '@nichoth/test-dom'
```

## example

### waitForText
```js
const el = await dom.waitForText({
    // `dom.qs` is a convenience function, short for `document.querySelector`
    element: dom.qs('.css-query'),
    regex: /foo/
})
```

### waitFor
```js
const el = await dom.waitFor({
    // css query here
    selector: 'p'
})
```

### qs
```js
// document.querySelector
const el = dom.qs('#my-css-id')
```

### qsa
```js
// document.querySelectorAll
const elements = dom.qsa('.my-css-class')
```

### click
Automate click events

```js
const element = dom.qs('#example')
dom.click(element)
```

## test
```
npm test
```

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