@1024pix/ember-testing-library

中文文档
4.0.1发布于 2026/09/30AGPL-3.0ES Module零依赖构建来源已验证近 30 天下载 1万

Package for Testing Library usage in Ember applications.

原始使用文档
文档目录4 节
  1. Installation
  2. Usage
  3. Acceptance test example:
  4. Integration test example:

@1024pix/ember-testing-library

The Ember Testing Library is a very lightweight solution for testing Ember components. It provides light utility functions on top of Ember built-in helpers, in a way that encourages better testing practices. Its primary guiding principle is:

  • The more your tests resemble the way your software is used, the more confidence they can give you.

For more info, please visit testing library guiding principles.

Installation

npm install -D @1024pix/ember-testing-library @testing-library/dom @ember/test-helpers

Usage

Ember testing library gives access to dom testing library queries in an Ember app. For more info on dom testing library queries, follow Testing library doc.

The current API methods that can be used are as follows:

  • getScreen
  • within
  • visit
  • render
  • clickByName
  • clickByText
  • fillByLabel
  • selectByLabelAndOption
  • selectOptionInRadioGroup
  • getByTextWithHtml
  • getAllByTextWithHtml
  • queryByTextWithHtml
  • queryAllByTextWithHtml
  • findByTextWithHtml
  • findAllByTextWithHtml

Please note that Ember Testing Library does not include the userEvent package, and that you should therefore use Ember built-in test helpers to interact with components and/or DOM nodes in integration/acceptance tests.

Acceptance test example:

import { visit } from '@1024pix/ember-testing-library';
import { click } from '@ember/test-helpers';

test('it should disable the button when clicked', async function (assert) {
  // given
  const screen = await visit('/home');

  // when
  const button = screen.getByRole('button', { name: 'Send message' });
  await click(button);

  // then
  assert.dom(button).isDisabled();
});

Integration test example:

import { render } from '@1024pix/ember-testing-library';
import { click } from '@ember/test-helpers';

test('it should disable the button when clicked', async function (assert) {
  // given
  const screen = await render(hbs`<LoginForm />`);

  // when
  const button = screen.getByRole('button', { name: 'Login' });
  await click(button);

  // then
  assert.dom(button).isDisabled();
});

版本与发布记录

@1024pix/ember-testing-library 共发布 67 个版本,首次发布于 2021/10/27;过去 12 个月发布了 19 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.0.1latest2026/09/301 个月前
3.0.442026/08/282 个月前
3.0.432026/08/282 个月前
3.0.422026/08/262 个月前
3.0.412026/07/103 个月前
3.0.402026/07/093 个月前

关于 @1024pix/ember-testing-library 的常见问题

@1024pix/ember-testing-library 是什么?

Package for Testing Library usage in Ember applications.

如何安装 @1024pix/ember-testing-library?

在项目目录运行 npm install @1024pix/ember-testing-library,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@ember/test-helpers(>=5)、@testing-library/dom(>=10)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@1024pix/ember-testing-library 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/1024pix__ember-testing-library 是否存在。

@1024pix/ember-testing-library 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@1024pix/ember-testing-library 可以商用吗?

@1024pix/ember-testing-library 使用 AGPL-3.0 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@1024pix/ember-testing-library 的下载量有多少?

根据 npm 官方下载统计,@1024pix/ember-testing-library 在 2026/10/04 – 2026/11/02 这 30 天内被下载 10,039 次,日均约 335 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@1024pix/ember-testing-library 还在维护吗?

最新版本 4.0.1 发布于 2026/09/30(1 个月前);至今共发布 67 个版本,其中过去 12 个月发布了 19 个;首次发布于 2021/10/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。