All Projects → simplabs → Ember Test Selectors

simplabs / Ember Test Selectors

Licence: mit
Enabling better element selectors in Ember.js tests

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Ember Test Selectors

flyway-junit5-extensions
Flyway JUnit 5 Extension to clean / migrate your database in tests.
Stars: ✭ 14 (-94.57%)
Mutual labels:  test
node-bogota
🚀 Run tape tests concurrently with tap-spec output
Stars: ✭ 15 (-94.19%)
Mutual labels:  test
robot-testing-framework
Robot Testing Framework (RTF)
Stars: ✭ 12 (-95.35%)
Mutual labels:  test
Hippolyte
HTTP Stubbing in Swift
Stars: ✭ 109 (-57.75%)
Mutual labels:  test
Test-Assignments
List of test assignments. ⚡
Stars: ✭ 85 (-67.05%)
Mutual labels:  test
xRetry
Retry running tests via Xunit and Specflow
Stars: ✭ 15 (-94.19%)
Mutual labels:  test
ttv
A command line tool for splitting files into test, train, and validation sets.
Stars: ✭ 38 (-85.27%)
Mutual labels:  test
zmock
zmock--http接口的mock平台
Stars: ✭ 98 (-62.02%)
Mutual labels:  test
kick-c64-dead-test
Kick assembler personalized version of the C=64 rev. 781220 Dead Test + more
Stars: ✭ 24 (-90.7%)
Mutual labels:  test
fake-sftp-server-rule
A JUnit rule that runs an in-memory SFTP server.
Stars: ✭ 34 (-86.82%)
Mutual labels:  test
ember-render-helpers
Complimentary render template helpers to the render modifiers
Stars: ✭ 19 (-92.64%)
Mutual labels:  ember
Robolectric-Instrumentation
Emulation of Android Instrumentation Framework API for Robolectric
Stars: ✭ 27 (-89.53%)
Mutual labels:  test
change-tracker-plugin
A Gradle plugin to help analyse the dependency between modules and run tasks only on modules impacted by specific set of changes.
Stars: ✭ 103 (-60.08%)
Mutual labels:  test
ember
@microstates/ember - Official Microstates bindings for Ember.js
Stars: ✭ 68 (-73.64%)
Mutual labels:  ember
percona-qa
Percona QA is a suite of scripts and utilities that assists in building, continuous integration, automated testing & bug reporting for Percona Server, Percona XtraDB Cluster, Percona XtraBackup, Percona Server for MongoDB, as well as other flavors of MySQL (Oracle, Facebook MyQSL, WebScaleSQL, MariaDB) etc.
Stars: ✭ 55 (-78.68%)
Mutual labels:  test
ember-local-storage-decorator
Decorator for Ember.js to read and persist data in localStorage
Stars: ✭ 13 (-94.96%)
Mutual labels:  ember
angular-webpack-skeleton
This project is deprecated. Please refer to https://github.com/Ks89/angular-cli-skeleton
Stars: ✭ 16 (-93.8%)
Mutual labels:  test
Ember Apollo Client
🚀 An ember-cli addon for Apollo Client and GraphQL
Stars: ✭ 257 (-0.39%)
Mutual labels:  ember
knuckle
Project configuration handler, without efforts
Stars: ✭ 14 (-94.57%)
Mutual labels:  test
puppeteer-screenshot-tester
Small library that allows us to compare screenshots generated by puppeteer in our tests.
Stars: ✭ 50 (-80.62%)
Mutual labels:  test

ember-test-selectors

Latest NPM release TravisCI Build Status

Enabling better element selectors in Ember.js tests

Features

  • Removes attributes starting with data-test- from HTML tags and component/helper invocations in your templates for production builds

  • Removes properties starting with data-test- from your JS objects like component classes for production builds

  • Automatically binds properties starting with data-test- on all components for development/testing builds

More information on why that is useful are available on our blog!

ember-test-selectors

Compatibility

  • Ember 3.8 or above
  • Ember CLI 3.8 or above
  • Node.js 10 or above

Installation

ember install ember-test-selectors

Usage

In your templates you are now able to use data-test-* attributes, which are automatically removed from production builds:

<article>
  <h1 data-test-post-title data-test-resource-id={{post.id}}>{{post.title}}</h1>
  <p>{{post.body}}</p>
  <button data-test-like-button>Like</button>
</article>

Once you've done that you can use attribute selectors to look up and interact with those elements:

assert.dom('[data-test-post-title]').hasText('Ember is great!');

await click('[data-test-like-button]');

Usage with Components

You can use the same syntax also for component invocations:

<Spinner @color="blue" data-test-spinner>

Inside the Spinner component template the data-test-spinner attribute will be applied to the element that has ...attributes on it, or on the component wrapper div element if you don't use tagName = ''.

Usage with Curly Components

If you still use the old curly invocation syntax for components you can pass data-test-* arguments to the components and they will automatically be bound on the wrapper element too:

{{spinner color="blue" data-test-spinner=true}}

Please note that the automatic argument binding only works for components based on @ember/component, but not @glimmer/component.

Usage in Ember addons

If you want to use ember-test-selectors in an addon make sure that it appears in the dependencies section of the package.json file, not in the devDependencies. This ensures that the selectors are also stripped correctly even if the app that uses the addon does not use ember-test-selectors itself.

Configuration

You can override when the data-test-* attributes should be stripped from the build by modifying your ember-cli-build.js file:

var app = new EmberApp({
  'ember-test-selectors': {
    strip: false
  }
});

strip accepts a Boolean value and defaults to !app.tests, which means that the attributes will be stripped for production builds, unless the build was triggered by ember test. That means that if you use ember test --environment=production the test selectors will still work, but for ember build -prod they will be stripped out.

License

ember-test-selectors is developed by and © simplabs GmbH and contributors. It is released under the MIT License.

ember-test-selectors is not an official part of Ember.js and is not maintained by the Ember.js Core Team.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].