# qunitx-dom

> High Level DOM Assertions for QUnit

Latest version **0.0.1** (published 2021-05-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install qunitx-dom
pnpm add qunitx-dom
yarn add qunitx-dom
bun add qunitx-dom
```

## Health

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

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

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2021-05-31 |
| First published | 2021-05-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | 10.* \|\| >= 12.* |
| Dependencies | 4 |
| Unpacked size | 196.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 181 |
| Author | simplabs GmbH |
| Maintainers | izelnakri |
| Keywords | browser, dom, ember-addon, html, qunit, qunit-plugin, testing |

## Links

- npm: https://www.npmjs.com/package/qunitx-dom
- Repository: https://github.com/simplabs/qunit-dom
- Homepage: https://github.com/simplabs/qunit-dom#readme
- Issues: https://github.com/simplabs/qunit-dom/issues
- npm.io page: https://npm.io/package/qunitx-dom

## Dependencies (4)

- [broccoli-funnel](https://npm.io/package/broccoli-funnel.md) ^3.0.3
- [ember-cli-babel](https://npm.io/package/ember-cli-babel.md) ^7.23.0
- [broccoli-merge-trees](https://npm.io/package/broccoli-merge-trees.md) ^4.2.0
- [ember-cli-version-checker](https://npm.io/package/ember-cli-version-checker.md) ^5.1.1

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2021-05-31

## README

qunit-dom
==============================================================================

[![TravisCI Build Status][travis-badge]][travis-badge-url]
[![Latest NPM release][npm-badge]][npm-badge-url]

[npm-badge]: https://img.shields.io/npm/v/qunit-dom.svg
[npm-badge-url]: https://www.npmjs.com/package/qunit-dom
[travis-badge]: https://img.shields.io/travis/simplabs/qunit-dom/master.svg
[travis-badge-url]: https://travis-ci.org/simplabs/qunit-dom

High Level DOM Assertions for [QUnit](https://qunitjs.com/)

```js
assert.dom('h1').exists();
assert.dom('h1').hasClass('title');
assert.dom('h1').hasText('Welcome to Ember, John Doe!');

assert.dom('input').isFocused();
assert.dom('input').hasValue(/.+ Doe/);
assert.dom('input').hasAttribute('type', 'text');
```


Install
------------------------------------------------------------------------------

### npm

```bash
npm install --save-dev qunit-dom
```

or using [`yarn`](https://yarnpkg.com/):

```bash
yarn add --dev qunit-dom
```

### Ember projects using `ember-qunit` v5.x and above

Import and run the `setup` function in your `test-helper.js` file:

```js
// tests/test-helper.js
import * as QUnit from 'qunit';
import { setup } from 'qunit-dom';

//...

setup(QUnit.assert);

setApplication(Application.create(config.APP));

start();

//...
```

This will attach the APIs to QUnit's `assert` object.

### Ember projects using `ember-qunit` v4.x and below

`qunit-dom` will automatically attach the APIs to QUnit's `assert` object. No extra setup required :tada:.

### `<script>` Tag

Load `qunit-dom.js` *after* `qunit.js`:

```html
<script src="https://unpkg.com/qunitjs/qunit/qunit.js"></script>
<script src="https://unpkg.com/qunit-dom/dist/qunit-dom.js"></script>
```


Usage
------------------------------------------------------------------------------

Once installed the DOM element assertions are available at `assert.dom(...).*`:

```js
test('the title is welcoming', function(assert) {
  assert.dom('#title').hasText('Welcome to QUnit');
});
```

**All available assertions are documented in [API.md](API.md).**

A basic codemod to automatically convert your assertions is available at
[https://github.com/simplabs/qunit-dom-codemod](https://github.com/simplabs/qunit-dom-codemod).


### TypeScript

`qunit-dom` includes type definition files, but the way it extends QUnit means
that you need import it somewhere so that TS and your editor can pick up the
types. It is recommended to add the following line to your
`tests/test-helper.ts` file:

```
import 'qunit-dom';
```

Rename your `tests/test-helper.js` to `.ts` if you do not have such a
file yet.

Contributing
------------------------------------------------------------------------------

See [CONTRIBUTING.md](CONTRIBUTING.md).

Related
------------------------------------------------------------------------------

- [chai-dom](https://github.com/nathanboktae/chai-dom) – DOM assertions for
  the Chai assertion library using vanilla JavaScript
- [chai-jquery](https://github.com/chaijs/chai-jquery) – jQuery assertions
  for chai


License
------------------------------------------------------------------------------

qunit-dom is developed by and &copy;
[simplabs GmbH](http://simplabs.com) and contributors. It is released under the
[MIT License](https://github.com/simplabs/qunit-dom/blob/master/LICENSE.md).

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