Code Monkey home page Code Monkey logo

qunit-dom's Introduction

qunit-dom

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

Install

npm

npm install --save-dev qunit-dom

or using yarn:

yarn add --dev qunit-dom

(This is the recommended method for Ember projects.)

<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

How to Run Tests

yarn test

How to Generate the Documentation

yarn docs

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 © simplabs GmbH and contributors. It is released under the MIT License.

qunit-dom's People

Contributors

adriancooney avatar alexzurek avatar beegan avatar brookjordan avatar bryancrotaz avatar ddoria921 avatar dependabot-support avatar dependabot[bot] avatar ember-tomster avatar happycollision avatar jayjayjpg avatar jelhan avatar lukemelia avatar marcoow avatar mikoscz avatar oreoz avatar pangratz avatar patocallaghan avatar raytiley avatar rtablada avatar scalvert avatar selvagsz avatar simonihmig avatar spencer516 avatar turbo87 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.