What is @ember/test-helpers?
@ember/test-helpers is a package that provides a set of utilities to facilitate testing in Ember.js applications. It offers a variety of helpers to interact with the DOM, handle asynchronous operations, and manage application state during tests.
What are @ember/test-helpers's main functionalities?
Rendering Helpers
Rendering helpers allow you to render components or templates in the test environment. This is useful for testing the output and behavior of your UI components.
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
await render(hbs`<MyComponent />`);
DOM Interaction
DOM interaction helpers enable you to simulate user interactions such as clicking buttons or filling in input fields. This helps in testing how your application responds to user actions.
import { click, fillIn } from '@ember/test-helpers';
await click('.my-button');
await fillIn('.my-input', 'new value');
Asynchronous Helpers
Asynchronous helpers like `settled` ensure that all asynchronous operations have completed before proceeding with the test. This is crucial for testing asynchronous behavior in your application.
import { settled } from '@ember/test-helpers';
await settled();
Routing Helpers
Routing helpers allow you to navigate to different routes within your application during tests. This is useful for testing the behavior of your application in different states and routes.
import { visit } from '@ember/test-helpers';
await visit('/my-route');
Other packages similar to @ember/test-helpers
ember-qunit
ember-qunit provides QUnit-specific helpers for testing Ember.js applications. It integrates seamlessly with @ember/test-helpers and offers additional utilities for setting up and tearing down tests.
ember-mocha
ember-mocha offers Mocha-specific helpers for testing Ember.js applications. Similar to ember-qunit, it works well with @ember/test-helpers and provides a Mocha-based testing environment.
ember-cli-page-object
ember-cli-page-object is a library for creating page objects in Ember.js tests. It provides a higher-level API for interacting with your application's UI, making tests more readable and maintainable.
@ember/test-helpers
A test-framework-agnostic set of helpers for testing Ember.js applications.
Usage
The exports of this library are intended to be utility functions that can be used to bring the
standard Ember testing experience to any testing framework.
This library is best used by way of a test-framework-specific
wrapper, such as ember-qunit or
ember-mocha.
Full documentation can be found in API.md.
Collaborating
Installation
git clone <repository-url>
this repositorycd ember-test-helpers
yarn install
Running
Running Tests
yarn test
(Runs ember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
Building
For more information on using ember-cli, visit https://ember-cli.com/.
Attribution
Much of ember-test-helpers
was extracted from the original ember-qunit
,
which was written by Stefan Penner, Robert Jackson, and Ryan Florence.
Copyright and License
Copyright 2015 Switchfly and contributors.
Dual-licensed under the Apache License, Version 2.0 and
the MIT License.