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');npm install --save-dev qunit-domor using yarn:
yarn add --dev qunit-dom(This is the recommended method for Ember projects.)
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>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.
yarn run testyarn run docs- chai-dom – DOM assertions for the Chai assertion library using vanilla JavaScript
- chai-jquery – jQuery assertions for chai
qunit-dom is developed by and © simplabs GmbH and contributors. It is released under the MIT License.