3.1.2 • Published 6 days ago

qunit-dom v3.1.2

Weekly downloads
146,862
License
MIT
Repository
github
Last release
6 days ago

qunit-dom

CI Build Status Latest NPM release

High Level DOM Assertions for QUnit

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');

!NOTE qunit-dom was written and is maintained by Mainmatter and contributors. We offer consulting, training, and team augmentation for web development teams – check out our website to learn more!

Install

npm

npm install --save-dev qunit-dom

or using yarn:

yarn add --dev qunit-dom

Ember projects using ember-qunit v6.x and above

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

// 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 < v6.x of ember-qunit

Install qunit-dom v2.0.0

<script> Tag

Load qunit-dom.js after qunit.js:

<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(...).*:

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

All available assertions are documented in API.md.

A basic codemod to automatically convert your assertions is available at 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.

Related

  • chai-dom – DOM assertions for the Chai assertion library using vanilla JavaScript
  • chai-jquery – jQuery assertions for chai

License

qunit-dom is developed by and © Mainmatter GmbH and contributors. It is released under the MIT License.

3.1.2

6 days ago

3.1.1

19 days ago

3.1.0

20 days ago

3.0.0-rc.2

7 months ago

3.0.0-rc.1

7 months ago

3.0.0

7 months ago

2.0.0

3 years ago

1.6.0

3 years ago

1.6.0-beta.2

3 years ago

1.6.0-beta.1

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.9.2

4 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.5

5 years ago

0.8.4

5 years ago

0.8.3

5 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.3

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.4

6 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.0

7 years ago