@badisi/wdio-harness

中文文档
5.0.0发布于 2026/10/25MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 3.2万

WebdriverIO support for Angular component test harnesses.

原始使用文档
文档目录4 节
  1. Installation
  2. Usage
  3. Development
  4. Contributing

@badisi/wdio-harness

🔬 WebdriverIO support for Angular component test harnesses.

npm version npm donwloads license

build status PRs welcome


Component test harnesses

A component harness is a class that lets a test interact with a component via a supported API. Each harness's API interacts with a component the same way a user would. By using the harness API, a test insulates itself against updates to the internals of a component, such as changing its DOM structure. The idea for component harnesses comes from the PageObject pattern commonly used for integration testing.

More info...


Installation

npm install @badisi/wdio-harness --save-dev
yarn add @badisi/wdio-harness --dev

Usage

Methods

  • createHarnessEnvironment(rootElement) - gets a HarnessLoader instance from a given element (defaults to body)
  • getHarness(harnessType, element) - searches for an harness instance from a given ComponentHarness class and element
  • getHarness(harnessType) - searches for an harness instance from a given ComponentHarness class
  • getHarness(query) - searches for an harness instance from a given HarnessPredicate
  • getAllHarnesses(query) - acts like getHarness, but returns an array of harness instances
  • waitForAngular() - waits for Angular to finish bootstrapping

Example

import '@angular/compiler'; // required since Angular v21
import { MatDatepickerInputHarness } from '@angular/material/datepicker/testing';
import { getHarness } from '@badisi/wdio-harness';

describe('Angular Material Harness', () => {
    beforeEach(async () => {
        await browser.url('http://localhost:4200');
    });

    it('MatDatePicker', async () => {
        const datepicker = await getHarness(MatDatepickerInputHarness.with({ selector: '#demo-datepicker-input' }));

        await datepicker.setValue('9/27/1954');
        expect(await datepicker.getValue()).withContext('Date should be 9/27/1954').toBe('9/27/1954');

        await datepicker.openCalendar();
        const calendar = await datepicker.getCalendar();
        await calendar.next();
        await calendar.selectCell({ text: '20' });
        expect(await datepicker.getValue()).withContext('Date should be 10/20/1954').toBe('10/20/1954');
    });
});

More examples here.

Development

See the developer docs.

Contributing

> Want to Help ?

Want to file a bug, contribute some code or improve documentation ? Excellent!

But please read up first on the guidelines for contributing, and learn about submission process, coding rules and more.

> Code of Conduct

Please read and follow the Code of Conduct and help me keep this project open and inclusive.

版本与发布记录

@badisi/wdio-harness 共发布 42 个版本,首次发布于 2021/11/16;过去 12 个月发布了 8 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.0.0latest2026/10/2513 天前
4.4.22026/10/2513 天前
4.4.12026/09/181 个月前
4.4.02026/07/123 个月前
4.3.42026/05/165 个月前
4.3.32026/04/146 个月前

关于 @badisi/wdio-harness 的常见问题

@badisi/wdio-harness 是什么?

WebdriverIO support for Angular component test harnesses.

如何安装 @badisi/wdio-harness?

在项目目录运行 npm install @badisi/wdio-harness,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:webdriverio(>= 10 < 11)、@angular/cdk(>= 13 < 22)、@wdio/logger(>= 10 < 11)、@wdio/globals(>= 10 < 11)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@badisi/wdio-harness 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@badisi/wdio-harness 支持 ESM 还是 CommonJS?

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

@badisi/wdio-harness 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^16.14.0 || >=18.10.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@badisi/wdio-harness 可以商用吗?

@badisi/wdio-harness 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@badisi/wdio-harness 的下载量有多少?

根据 npm 官方下载统计,@badisi/wdio-harness 在 2026/10/08 – 2026/11/06 这 30 天内被下载 32,493 次,日均约 1,083 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@badisi/wdio-harness 还在维护吗?

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