258 sao GitHub và vẫn tăng — emberjs/ember-qunit là dự án JavaScript mà TopGit đang theo dõi trên nền tảng. QUnit test helpers for Ember
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
ember-qunit simplifies testing of Ember applications with
QUnit by providing QUnit-specific wrappers around the
helpers contained in
ember-test-helpers.
Requirements
Ember.js v4.0 or above
Ember Auto Import v2 or above (or Embroider)
Node.js v16 or above
TypeScript 4.8 and 4.9
SemVer policy: simple majors
The public API is defined by the Usage section below.
ember-cli ~v4.8.1, ~v4.12.2, >= v5.1
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.
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.
Load Tests
In environments that use the AMD Loader, loadTests() will need to be called
before start().
import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';
import { loadTests } from 'ember-qunit/test-loader';
setApplication(Application.create(config.APP));
loadTests()
start();
In ESM environments, this isn't needed as import.meta.glob can load test files.
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()
sets up the DOM Interaction Helpers
from @ember/test-helpers (click(), fillIn(), ...)
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, find } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('GravatarImageComponent', function(hooks) {
setupRenderingTest(hooks);
test('renders', async function() {
await render(hbs`{{gravatar-image}}`);
assert.ok(find('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:
Boot your application instance
Set up all the DOM Interaction Helpers
(click(), fillIn(), ...) as well as the Routing Helpers
(visit(), currentURL(), ...) from @ember/test-helpers
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(), '/');
});
});
Configuration
Configuration is optionally managed via @embroider/macros
To configure ember-qunit, in your ember-cli-build.js, add:
'use strict';
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function (defaults) {
const app = new EmberApp(defaults, {
'@embroider/macros': {
setConfig: {
'ember-qunit': {
/**
* default: false
*
* removes the CSS for the test-container (where the app and components are rendered to)
*/
disableContainerStyles: true,
/**
* default: 'qunit-default'
* options: 'qunit-default' | 'ember'
*
* 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.
*/
theme: 'qunit-default',
},
},
},
/* ... */
});
/* ... */
};
Contributing
Installation
git clone <repository-url>
cd ember-qunit
pnpm install
Running tests
pnpm test (Runs ember try:each to test your addon against multiple Ember versions)
ember test
ember test --server
Running the dummy application
ember serve
Visit the dummy application at http://localhost:4200.
For more information on using ember-cli, visit https://ember-cli.com/.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/emberjs/ember-qunit là nguồn chính thức.
emberjs/ember-qunit có bao nhiêu sao?
emberjs/ember-qunit có 258 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/emberjs/ember-qunit. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
emberjs/ember-qunit có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho emberjs/ember-qunit. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
emberjs/ember-qunit còn đang phát triển không?
Commit gần nhất trên emberjs/ember-qunit là 1 tháng trước (theo timestamp GitHub). Repo có 154 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
emberjs/ember-qunit là gì?
emberjs/ember-qunit (emberjs/ember-qunit) là dự án JavaScript trên GitHub. Theo mô tả gốc: QUnit test helpers for Ember
Đọc đầy đủ README ở tab phía trên.
Chưa chắc ember-qunit có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về ember-qunit.