Skip to content

yratanov/ember-page-object-asserts

Repository files navigation

ember-page-object-asserts

TravisCI Build Status codecov Maintainability Dependabot enabled

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).text.is("test"); //message 'page.element: text is "text"'
assert.po(page.link).href.is('google.com'); //message 'page.link: href is "google.com"'
assert.po(page.link).href.includes('google.com'); //message 'page.link: href includes "google.com"'
assert.po(page.link).isHighlighted(); //message 'page.link: is highlighted'
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

is/isNot
assert.po(page.element).text.is("test");
assert.po(page.element).text.isNot("test");
assert.po(page.input).value.is('test');
includes/doesNotInclude
assert.po(page.element).text.includes("test");
assert.po(page.element).text.doesNotInclude("test");
isPresent/isHidden
assert.po(page.input).isPresent();
assert.po(page.input).isHidden();
Collections
const page = create({
  list: collection('li')
});

assert.po(page.list).length.is(3);
Properties as asserts
const page = create({
  link: {
    isHighlighted: hasClass('highlighted'),
  },
});

assert.po(page.list).isHighlighted();
assert.po(page.list).isHighlighted(false);

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.