在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):emberjs/ember-qunit开源软件地址(OpenSource Url):https://github.com/emberjs/ember-qunit开源编程语言(OpenSource Language):JavaScript 95.8%开源软件介绍(OpenSource Introduction):ember-qunitember-qunit simplifies testing of Ember applications with QUnit by providing QUnit-specific wrappers around the helpers contained in ember-test-helpers. Requirements
If you need support for Node 4 or older Ember CLI versions please use v3.x of this addon. Installation
$ ember install ember-qunit Some other addons are detecting the test framework based on the installed
addon names and are expecting UpgradingFor instructions how to upgrade to the latest version, please read our Migration Guide. UsageThe 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 ApplicationYour 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 Setup TestsThe It will setup your test context with:
For example, the following is a unit test for the 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 TestsThe It will setup your test context the same way as
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 TestsThe On top of
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(), '/');
});
}); ContributingInstallation
Running tests
Running the dummy application
For more information on using ember-cli, visit https://ember-cli.com/. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论