All Projects → emberjs → Ember Qunit

emberjs / Ember Qunit

Licence: mit
QUnit test helpers for Ember

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ember Qunit

Python
All Algorithms implemented in Python
Stars: ✭ 125,688 (+48805.84%)
Mutual labels:  hacktoberfest
Industrial Iot
Azure Industrial IoT Platform
Stars: ✭ 256 (-0.39%)
Mutual labels:  hacktoberfest
Kratos
Next-gen identity server (think Auth0, Okta, Firebase) with Ory-hardened authentication, MFA, FIDO2, profile management, identity schemas, social sign in, registration, account recovery, and IoT auth. Golang, headless, API-only - without templating or theming headaches.
Stars: ✭ 4,684 (+1722.57%)
Mutual labels:  hacktoberfest
Free Programming Books
📚 Freely available programming books
Stars: ✭ 216,030 (+83958.37%)
Mutual labels:  hacktoberfest
Stock Analysis
Regression, Scrapers, and Visualization
Stars: ✭ 255 (-0.78%)
Mutual labels:  hacktoberfest
Gentoo Docker Images
[MIRROR] Common effort to get an official and automated gentoo base docker container
Stars: ✭ 256 (-0.39%)
Mutual labels:  hacktoberfest
Material Ui
MUI (formerly Material-UI) is the React UI library you always wanted. Follow your own design system, or start with Material Design.
Stars: ✭ 73,739 (+28592.22%)
Mutual labels:  hacktoberfest
Netescapades.aspnetcore.securityheaders
Small package to allow adding security headers to ASP.NET Core websites
Stars: ✭ 256 (-0.39%)
Mutual labels:  hacktoberfest
Massivedecks
A comedy party game for PC, mobile & chromecast.
Stars: ✭ 254 (-1.17%)
Mutual labels:  hacktoberfest
Ngx Smart Modal
Modal/Dialog component crafted for Angular
Stars: ✭ 256 (-0.39%)
Mutual labels:  hacktoberfest
Hosting
This is a setup for a Tor based shared web hosting server
Stars: ✭ 254 (-1.17%)
Mutual labels:  hacktoberfest
Parsl
Parsl - Parallel Scripting Library
Stars: ✭ 253 (-1.56%)
Mutual labels:  hacktoberfest
Libiio
A cross platform library for interfacing with local and remote Linux IIO devices
Stars: ✭ 256 (-0.39%)
Mutual labels:  hacktoberfest
Ohmyzsh
🙃 A delightful community-driven (with 1900+ contributors) framework for managing your zsh configuration. Includes 300+ optional plugins (rails, git, macOS, hub, docker, homebrew, node, php, python, etc), 140+ themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.
Stars: ✭ 138,057 (+53618.68%)
Mutual labels:  hacktoberfest
Canvg
Javascript SVG parser and renderer on Canvas
Stars: ✭ 2,963 (+1052.92%)
Mutual labels:  hacktoberfest
30 Seconds Of Code
Short JavaScript code snippets for all your development needs
Stars: ✭ 89,121 (+34577.43%)
Mutual labels:  hacktoberfest
Netket
Machine learning algorithms for many-body quantum systems
Stars: ✭ 256 (-0.39%)
Mutual labels:  hacktoberfest
Beautiful Open
Handsome sites for open source software
Stars: ✭ 257 (+0%)
Mutual labels:  hacktoberfest
Kube Hunter
Hunt for security weaknesses in Kubernetes clusters
Stars: ✭ 3,399 (+1222.57%)
Mutual labels:  hacktoberfest
Women Teaching Tech
Uma lista de canais ou cursos sobre tecnologia feitos por mulheres.
Stars: ✭ 256 (-0.39%)
Mutual labels:  hacktoberfest

ember-qunit

Latest NPM release CI Build Status

ember-qunit simplifies testing of Ember applications with QUnit by providing QUnit-specific wrappers around the helpers contained in ember-test-helpers.

Requirements

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

If you need support for Node 4 or older Ember CLI versions please use v3.x of this addon.

Installation

ember-qunit is an Ember CLI addon, so install it as you would any other addon:

$ ember install ember-qunit

Some other addons are detecting the test framework based on the installed addon names and are expecting ember-cli-qunit instead. If you have issues with this then ember install ember-cli-qunit, which should work exactly the same.

Upgrading

For instructions how to upgrade to the latest version, please read our Migration Guide.

Usage

The following section describes the use of ember-qunit with the latest modern Ember testing APIs, as laid out in the RFCs 232 and 268.

For the older APIs have a look at our Legacy Guide.

Setting the Application

Your tests/test-helper.js file should look similar to the following, to correctly setup the application required by @ember/test-helpers:

import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';

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

start();

Also make sure that you have set ENV.APP.autoboot = false; for the test environment in your config/environment.js.

Setup Tests

The setupTest() function can be used to setup a unit test for any kind of "module/unit" of your application that can be looked up in a container.

It will setup your test context with:

  • this.owner to interact with Ember's Dependency Injection system
  • this.set(), this.setProperties(), this.get(), and this.getProperties()
  • this.pauseTest() method to allow easy pausing/resuming of tests

For example, the following is a unit test for the SidebarController:

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('SidebarController', function(hooks) {
  setupTest(hooks);

  // Replace this with your real tests.
  test('exists', function() {
    let controller = this.owner.lookup('controller:sidebar');
    assert.ok(controller);
  });
});

Setup Rendering Tests

The setupRenderingTest() function is specifically designed for tests that render arbitrary templates, including components and helpers.

It will setup your test context the same way as setupTest(), and additionally:

  • Initializes Ember's renderer to be used with the Rendering helpers, specifically render()
  • Adds this.element to your test context which returns the DOM element representing the wrapper around the elements that were rendered via render()
  • sets up the DOM Interaction Helpers from @ember/test-helpers (click(), fillIn(), ...)
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('GravatarImageComponent', function(hooks) {
  setupRenderingTest(hooks);

  test('renders', async function() {
    await render(hbs`{{gravatar-image}}`);
    assert.ok(this.element.querySelector('img'));
  });
});

Setup Application Tests

The setupApplicationTest() function can be used to run tests that interact with the whole application, so in most cases acceptance tests.

On top of setupTest() it will:

import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { visit, currentURL } from '@ember/test-helpers';

module('basic acceptance test', function(hooks) {
  setupApplicationTest(hooks);

  test('can visit /', async function(assert) {
    await visit('/');
    assert.equal(currentURL(), '/');
  });
});

Contributing

Installation

  • git clone <repository-url>
  • cd ember-qunit
  • npm install

Running tests

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

Running the dummy application

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

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].