Gathering detailed insights and metrics for ember-qunit
Gathering detailed insights and metrics for ember-qunit
Gathering detailed insights and metrics for ember-qunit
Gathering detailed insights and metrics for ember-qunit
npm install ember-qunit
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
259 Stars
1,605 Commits
154 Forks
20 Watching
16 Branches
84 Contributors
Updated on 01 Nov 2024
JavaScript (75.7%)
TypeScript (16.28%)
HTML (5.63%)
CSS (2.36%)
Handlebars (0.03%)
Cumulative downloads
Total Downloads
Last day
-32%
19,188
Compared to previous day
Last week
-20.3%
119,483
Compared to previous week
Last month
18.1%
611,411
Compared to previous month
Last year
9.2%
7,430,460
Compared to previous year
3
23
ember-qunit simplifies testing of Ember applications with QUnit by providing QUnit-specific wrappers around the helpers contained in ember-test-helpers.
If you need support for Node 14 please use v6.2 of this addon.
If you need support for Node 13 or older Ember CLI versions please use v4.x of this addon.
ember-qunit
is an Ember CLI addon, so install it
as you would any other addon:
1$ 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.
For instructions how to upgrade to the latest version, please read our Migration Guide.
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.
Your tests/test-helper.js
file should look similar to the following, to
correctly setup the application required by @ember/test-helpers
:
1import Application from '../app'; 2import config from '../config/environment'; 3import { setApplication } from '@ember/test-helpers'; 4import { start } from 'ember-qunit'; 5 6setApplication(Application.create(config.APP)); 7 8start();
Also make sure that you have set ENV.APP.autoboot = false;
for the test
environment in your config/environment.js
.
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
systemthis.set()
, this.setProperties()
, this.get()
, and this.getProperties()
this.pauseTest()
method to allow easy pausing/resuming of testsFor example, the following is a unit test for the SidebarController
:
1import { module, test } from 'qunit'; 2import { setupTest } from 'ember-qunit'; 3 4module('SidebarController', function(hooks) { 5 setupTest(hooks); 6 7 // Replace this with your real tests. 8 test('exists', function() { 9 let controller = this.owner.lookup('controller:sidebar'); 10 assert.ok(controller); 11 }); 12});
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:
render()
@ember/test-helpers
(click()
, fillIn()
, ...)1import { module, test } from 'qunit'; 2import { setupRenderingTest } from 'ember-qunit'; 3import { render, find } from '@ember/test-helpers'; 4import { hbs } from 'ember-cli-htmlbars'; 5 6module('GravatarImageComponent', function(hooks) { 7 setupRenderingTest(hooks); 8 9 test('renders', async function() { 10 await render(hbs`{{gravatar-image}}`); 11 assert.ok(find('img')); 12 }); 13});
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:
click()
, fillIn()
, ...) as well as the Routing Helpers
(visit()
, currentURL()
, ...) from @ember/test-helpers
1import { module, test } from 'qunit'; 2import { setupApplicationTest } from 'ember-qunit'; 3import { visit, currentURL } from '@ember/test-helpers'; 4 5module('basic acceptance test', function(hooks) { 6 setupApplicationTest(hooks); 7 8 test('can visit /', async function(assert) { 9 await visit('/'); 10 assert.equal(currentURL(), '/'); 11 }); 12});
Configuration is optionally managed via @embroider/macros
To configure ember-qunit
, in your ember-cli-build.js
, add:
1'use strict';
2
3const EmberApp = require('ember-cli/lib/broccoli/ember-app');
4
5module.exports = function (defaults) {
6 const app = new EmberApp(defaults, {
7 '@embroider/macros': {
8 setConfig: {
9 'ember-qunit': {
10 /**
11 * default: false
12 *
13 * removes the CSS for the test-container (where the app and components are rendered to)
14 */
15 disableContainerStyles: true,
16 /**
17 * default: 'qunit-default'
18 * options: 'qunit-default' | 'ember'
19 *
20 * Sets the theme for the Web UI of the test runner. Use a different value to disable loading any theme, allowing you to provide your own external one.
21 */
22 theme: 'qunit-default',
23 },
24 },
25 },
26 /* ... */
27 });
28
29 /* ... */
30};
git clone <repository-url>
cd ember-qunit
pnpm install
pnpm test
(Runs ember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
ember serve
For more information on using ember-cli, visit https://ember-cli.com/.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
9 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 7
Reason
Found 4/8 approved changesets -- score normalized to 5
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
26 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More