Skip to content

`Ember.Test.find` your data-test-* attrs without any shenanigans

License

Notifications You must be signed in to change notification settings

fauxton/ember-test-selectors-helpers

Repository files navigation

ember-test-selectors-helpers

Overrides the default Ember.Test.find helper in order to make querying ember-test-selectors' data-test-* attributes as straightforward as possible.

Background

Previously, that addon shipped with a testSelector test helper that expanded a given string to make querying these attributes more straightforward, but it was recently deprecated and will be removed in an upcoming version.

Here's what that used to look like:

Given the following Handlebars template:

<div data-test-my-div>My Div</div>

Here's how you might have used the testSelector helper in an acceptance test:

import testSelector from 'ember-test-selectors';

...

test('an element is present', function(assert) {
  assert.ok(findWithAssert(testSelector('my-div')), 'My div is present');
});

With this addon, there's no need for the ceremony. It's as if Ember.js shipped with support for using data-test-* attributes out of the box:

test('an element is present', function(assert) {
  assert.ok(findWithAssert('my-div'), 'My div is present');
});

The string my-div will automatically be expanded to the proper selector, assuming it is a hyphenated string. Otherwise, it will behave as the default find helper does.

Installation

You can install this addon by running

$ ember install ember-test-selectors-helpers

Afterwards, you'll need to import the test selectors before the startApp() helper is run:

import overrideHelpers from './helper-overrides';

overrideHelpers();

// startApp()

Running

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit https://ember-cli.com/.

About

`Ember.Test.find` your data-test-* attrs without any shenanigans

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published