ro0gr / ember-page-object-asserts

QUnit asserts for https://github.com/san650/ember-cli-page-object

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ember-page-object-asserts

TravisCI Build Status

Adds QUnit asserts for ember-cli-page-object to make test errors more user-friendly and make code shorter.

Why?

User-friendly messages and simpler syntax:

const page = create({
  link: {
    scope: 'a',
    href: attribute('href'),
    isHighlighted: hasClass('highlighted'),
  },
});

assert.po(page.element).hasText("test"); //message 'page.element: has text "text"'
assert.po(page.link).href('google.com'); //message 'page.link: has href "google.com"'
assert.po(page.link).isHighlighted(); //message 'page.link: isHighlighted
assert.po(page.input).isPresent();  //message 'page.input: is present'

Compatibility

  • Ember.js v2.18 or above
  • Ember CLI v2.13 or above
  • Node.js v8 or above

Installation

ember install ember-page-object-asserts

Usage

Import new assert in your tests/test-helper.js file:

import { addPoAssert } from 'ember-page-object-asserts';

addPoAssert();

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

Built-in asserts

hasText/hasNoText
assert.po(page.element).hasText("test");
assert.po(page.element).hasText(/test/);

assert.po(page.element).hasNoText("test");
assert.po(page.element).hasNoText(/test/);
has
const page = create({
  link: {
    scope: 'a',
    href: attribute('href'),
    isHighlighted: hasClass('highlighted'),
  },
});

assert.po(page.link).has('href', 'google.com');
assert.po(page.link).has('isHighlighted');

// Or even like this:

assert.po(page.link).isHighlighted();
assert.po(page.link).href('google.com');
isPresent/isHidden
assert.po(page.input).isPresent();
assert.po(page.input).isHidden();
hasValue
assert.po(page.input).hasValue('test');
hasItems
const page = create({
  list: collection('li')
});

assert.po(page.list).hasItems(3);

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

About

QUnit asserts for https://github.com/san650/ember-cli-page-object

License:MIT License


Languages

Language:JavaScript 74.8%Language:TypeScript 19.3%Language:HTML 5.9%