# @globalpayments/vega-testing-library 中文文档

规范地址：https://npmcn.com/package/%40globalpayments/vega-testing-library/

版本：1\.3\.4
npm 元数据更新时间：2026-11-05T10:11:08.231Z
中文译文更新时间：2026-11-16T16:17:54.872Z
软件包许可：UNLICENSED

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40globalpayments/vega-testing-library
原文对照：https://npmcn.com/package/%40globalpayments/vega-testing-library/?lang=original
项目主页：https://github.com/heartlandpayments/Vega#readme
源码仓库：https://github.com/heartlandpayments/Vega

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：585 kB，311 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：1 个
- peer 依赖：@globalpayments/vega \*
- 首次发布：2026-05-28T09:14:27.088Z
- 最新版本发布：2026-05-28T09:14:27.378Z
- 近 30 天下载量：3760（2026-10-17 至 2026-11-15，npm 官方下载统计）
- 已发布版本数：2（近 12 个月 2 个）

## 中文简介

一个轻量级测试工具,可以扩展出@testing-library/user-event,以无缝模拟用户与Vega Web组件的互动.

## 安装

```sh
npm install @globalpayments/vega-testing-library
```

也可以使用：`pnpm add @globalpayments/vega-testing-library`、`yarn add @globalpayments/vega-testing-library`、`bun add @globalpayments/vega-testing-library`

## README

# 虚拟测试- 图书馆

## 安装

```bash
npm install @globalpayments/vega-testing-library
```

## 什么是用户Event api

用户- event 是测试库的辅助库, 通过发送如果交互发生在浏览器中而会发生的事件来模拟用户交互

## 为什么我们需要扩展用户事件 API

目前,在使用测试库进行交互操作时,由于使用了Shadow DOM,找到可触发元素变得非常麻烦和繁琐

```
const shadowInput: Element = document
.querySelector("vega-input")
?.shadowRoot?.querySelector("input") as Element;

userEvent.type(shadowInput, "input text");
```

## 何时使用此库

涉及用户互动的组件应全部使用此库来简化操作,使用户事件简单高效.

## 使用量

### `waitForVega` ——选择正确的导入

有两个 `waitForVega` 维加生态系统中的功能。 对上下文使用正确的:

| A. 背景情况 | 从 | 页:1 |
| :-- | :-- | --- |
| **生产/应用代码** | `@globalpayments/vega` | 等待网页上所有Vega网络组件的水合. 没有延迟,没有试验框架的组合. |
| **测试代码** | `@globalpayments/vega-testing-library` | 以上超集: 也等待可选的后水分延迟和 **支持 Jest 假定时器** 自动. |

```ts
// ✅ In tests — use the testing-library version
import { waitForVega } from '@globalpayments/vega-testing-library';

it('renders the button label', async () => {
  render(<MyComponent />);
  await waitForVega(); // supports jest.useFakeTimers(), optional delay param (default 300 ms)
  // Optional: pass a custom delay when a test needs additional render settling time
  // await waitForVega(500);
  expect(screen.getByText('Submit')).toBeInTheDocument();
});
```

```ts
// ✅ In application / production code — use the core version
import { waitForVega } from '@globalpayments/vega';

async function initPage() {
    await waitForVega(); // waits for hydration only
}
```

`waitForVegaReady` 从 `@globalpayments/vega-angular`, (中文(简体) ), `@globalpayments/vega-react`,以及 `@globalpayments/vega-vue` 实值 **已贬值**。迁移到 `waitForVega` 从 `@globalpayments/vega-testing-library`数字 :

```ts
// Before (deprecated)
import { waitForVegaReady } from '@globalpayments/vega-angular/testing';
const result = await waitForVegaReady(renderResult);

// After
import { waitForVega } from '@globalpayments/vega-testing-library';
await waitForVega();
```

### `mockResizeObserver`

替换全局 `ResizeObserver` 带有可控模拟器,用于决定大小调整活动。 以前每个框架包件库都单独提供,现在合并到这里.

```ts
import { mockResizeObserver, MockedResizeObserverController } from '@globalpayments/vega-testing-library';

let resizeController: MockedResizeObserverController;

beforeEach(() => {
    resizeController = mockResizeObserver();
});

it('hides element when height is 0', () => {
    resizeController.hide('.my-element');
    expect(screen.queryByText('Content')).not.toBeVisible();
});
```

`mockResizeObserver` 从 `@globalpayments/vega-angular`, (中文(简体) ), `@globalpayments/vega-react`,以及 `@globalpayments/vega-vue` 实值 **已贬值**。从 `@globalpayments/vega-testing-library`。 。 。 .

### 假定时器兼容性

`vega-testing-library` 所有内部变速器的自动推进器, 包括内部 `waitForVega`。使用 `jest.useFakeTimers()` 能够全部使用 `userForVega` APIs和 `waitForVega` 无需手动呼叫 `jest.advanceTimersByTime(...)`。 。 。 .

如果你的测试也有自己的解禁逻辑, 你仍然可以明确提前计时器 在您的断言流 视需要.

### 五十四国

```
npm i @testing-library/user-event -D
npm i @globalpayments/vega-testing-library -D
```

```
import userEvent, { UserEvent } from '@testing-library/user-event'; // v14
import { createUserEventForVega, CompatibleUserEventMethods, UserEventCompatible } from '@globalpayments/vega-testing-library';
let user: UserEvent = userEvent.setup();
const userForVega: CompatibleUserEventMethods<UserEventCompatible> = createUserEventForVega(user);
// Example using vega-input
const vegaInputElement = document.querySelector('vega-input');
await userForVega.type(vegaInputElement, 'input text');
expect(vegaInputElement.value).toBe('input text');
....
```

### V13型

```
npm i @testing-library/user-event@13.5.0 -D
npm i @globalpayments/vega-testing-library -D
```

```
import userEvent from '@testing-library/user-event'; // v13
import { createUserEventForVega, CompatibleUserEventMethods, UserEventType13 } from '@globalpayments/vega-testing-library';
const userForVega: CompatibleUserEventMethods<UserEventType13<typeof userEvent>> = createUserEventForVega(userEvent);
// Example using vega-input
const vegaInputElement = document.querySelector('vega-input');
userEvent.type(vegaInputElement, 'input text');
expect(vegaInputElement.value).toBe('input text');
....
```

## 支助构成部分

| **组件名称** | **支持用户事件 API** |
| :-- | :-- |
| **维加星等** | [**单击**: 模拟用户点击手风琴](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaAccordion); // will click to toggle expand`  
`V13`  
`userForVega.click(vegaAccordion); // will click to toggle expand`  
  
[**盘旋**:模拟用户在手风琴上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaAccordion); // will hover toggle button`  
`V13`  
`userForVega.hover(vegaAccordion); // will hover toggle button`  
  
[**卸载**:模拟用户将指针移出手风琴](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaAccordion); // will unhover toggle button`  
`V13`  
`userForVega.unhover(vegaAccordion); // will unhover toggle button`  
 |
| **维加-面包屑b** | [**单击**: 模拟点击面包屑的用户](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaBreadcrumb, { index: 0 }); // will click breadcrumb item by index`  
`await userForVega.click(vegaBreadcrumb, { label: 'level2' }); // will click item by label (visible or in dropdown)`  
`V13`  
`userForVega.click(vegaBreadcrumb, undefined, { index: 0 }); // will click breadcrumb item by index`  
`userForVega.click(vegaBreadcrumb, undefined, { label: 'level2' }); // will click item by label (visible or in dropdown)`  
  
[**盘旋**:模拟用户在面包屑上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaBreadcrumb, { index: 0 }); // will hover breadcrumb item by index`  
`await userForVega.hover(vegaBreadcrumb, { label: 'level2' }); // will hover item by label (visible or in dropdown)`  
`V13`  
`userForVega.hover(vegaBreadcrumb, undefined, { index: 0 }); // will hover breadcrumb item by index`  
`userForVega.hover(vegaBreadcrumb, undefined, { label: 'level2' }); // will hover item by label (visible or in dropdown)`  
  
[**卸载**:模拟用户将指针移出面包屑](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaBreadcrumb, { index: 0 }); // will unhover breadcrumb item by index`  
`await userForVega.unhover(vegaBreadcrumb, { label: 'level2' }); // will unhover item by label (visible or in dropdown)`  
`V13`  
`userForVega.unhover(vegaBreadcrumb, undefined, { index: 0 }); // will unhover breadcrumb item by index`  
`userForVega.unhover(vegaBreadcrumb, undefined, { label: 'level2' }); // will unhover item by label (visible or in dropdown)`  
 |
| **维加按钮** | [**单击**: 模拟用户点击按钮](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaButton); // will click button`  
`V13`  
`userForVega.click(vegaButton); // will click button`  
  
[**盘旋**: 模拟用户在按钮上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaButton); // will hover button`  
`V13`  
`userForVega.hover(vegaButton); // will hover button`  
  
[**卸载**:模拟用户将指针移出按钮](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaButton); // will unhover button`  
`V13`  
`userForVega.unhover(vegaButton); // will unhover button`  
 |
| **虚拟按钮圈** | [**单击**: 模拟点击按钮圆的用户](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaButtonCircle); // will click button circle`  
`V13`  
`userForVega.click(vegaButtonCircle); // will click button circle`  
  
[**盘旋**:模拟用户在按钮圆上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaButtonCircle); // will hover button circle`  
`V13`  
`userForVega.hover(vegaButtonCircle); // will hover button circle`  
  
[**卸载**:模拟一个用户将指针从按钮圆移出](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaButtonCircle); // will unhover button circle`  
`V13`  
`userForVega.unhover(vegaButtonCircle); // will unhover button circle`  
 |
| **维加- 按钮链接** | [**单击**: 模拟点击按钮链接的用户](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaButtonLink); // will click button link`  
`V13`  
`userForVega.click(vegaButtonLink); // will click button link`  
  
[**盘旋**:模拟用户在按钮链接上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaButtonLink); // will hover button link`  
`V13`  
`userForVega.hover(vegaButtonLink); // will hover button link`  
  
[**卸载**:模拟用户将指针移出按钮链接](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaButtonLink); // will unhover button link`  
`V13`  
`userForVega.unhover(vegaButtonLink); // will unhover button link`  
 |
| **维加胡萝卜** | [**单击**:模拟点击旋转木马的用户](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaCarousel); // Click page 1`  
`await userForVega.click(vegaCarousel, { page: 2 }); // Click page 2`  
`V13`  
`userForVega.click(vegaCarousel); // Click page 1`  
`userForVega.click(vegaCarousel, undefined, { page: 2 }); // Click page 2`  
  
[**盘旋**:模拟用户在旋转木马上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaCarousel); // Hover on carousel`  
`V13`  
`userForVega.hover(vegaCarousel); // Hover on carousel`  
  
[**卸载**:模拟用户将指针移出旋转木马](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaCarousel); // Unhover on carousel`  
`V13`  
`userForVega.unhover(vegaCarousel); // Unhover on carousel`  
 |
| **vega 检查框** | [**单击**: 模拟用户点击复选框](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaCheckbox); // will click checkbox`  
`V13`  
`userForVega.click(vegaCheckbox); // will click checkbox`  
  
[**盘旋**: 模拟一个用户在复选框上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaCheckbox); // will hover checkbox`  
`V13`  
`userForVega.hover(vegaCheckbox); // will hover checkbox`  
  
[**卸载**:模拟用户将指针移出复选框](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaCheckbox); // will unhover checkbox`  
`V13`  
`userForVega.unhover(vegaCheckbox); // will unhover checkbox`  
 |
| **维加芯片** | [**单击**:模拟点击芯片的用户](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaChip, { iconClose: true }); // will click close icon`  
`await userForVega.click(vegaChip); // will click vega-chip button`  
`V13`  
`userForVega.click(vegaChip, { iconClose: true }); // will click close icon`  
`userForVega.click(vegaChip); // will click vega-chip button`  
  
[**盘旋**:模拟用户在芯片上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaChip); // will hover chip`  
`V13`  
`userForVega.hover(vegaChip); // will hover chip`  
  
[**卸载**:模拟用户将指针移出芯片](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaChip); // will unhover chip`  
`V13`  
`userForVega.unhover(vegaChip); // will unhover chip`  
 |
| **彩色选手** | [**单击**: 模拟用户点击取色器](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaColorPicker, {value: '#00BBFF'}); // will selected the color`  
`V13`  
`userForVega.click(vegaColorPicker, undefined, {value: '#00BBFF'}); // will selected the color`  
 |
| **虚拟组合** | [**清除**: 模拟用户清除组合框的值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaComboBox, 'key', {keyOrLabel: 'key'}); // will clear chip by key`  
`await userForVega.clear(vegaComboBox, 'label', {keyOrLabel: 'label'}); // will clear chip by label`  
`await userForVega.clear(vegaComboBox, ['label', ...], {keyOrLabel: 'label'}); // will clear multiple chips by label`  
`await userForVega.clear(vegaComboBox, ['key', ...], {keyOrLabel: 'key'}); // will clear multiple chips by key`  
`V13`  
`userForVega.clear(vegaComboBox, 'key', {keyOrLabel: 'key'}); // will clear chip by key`  
`userForVega.clear(vegaComboBox, 'label', {keyOrLabel: 'label'}); // will clear chip by label`  
`userForVega.clear(vegaComboBox, ['label', ...], {keyOrLabel: 'label'}); // will clear multiple chips by label`  
`userForVega.clear(vegaComboBox, ['key', ...], {keyOrLabel: 'key'}); // will clear multiple chips by key`  
  
[**单击**: 模拟用户点击组合框](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaComboBox, {triggerDynamicAdd: true}); // will trigger the "Add" button in the dropdown`  
`V13`  
`userForVega.click(vegaComboBox, undefined, {triggerDynamicAdd: true}); // will trigger the "Add" button in the dropdown`  
  
[**取消选择选项**: 模拟用户从多选项中取消选择选项](https://testing-library.com/docs/user-event/utility#-selectoptions-deselectoptions)  
用法示例:  
`V14`  
`await userForVega.deselectOptions(vegaComboBox, ['key', ...], {keyOrLabel: 'key'}); // will deselect the options according to key`  
`await userForVega.deselectOptions(vegaComboBox, ['label', ...], {keyOrLabel: 'label'}); // will deselect the options according to label`  
`V13`  
`userForVega.deselectOptions(vegaComboBox, ['key', ...], {keyOrLabel: 'key'}); // will deselect the options according to key`  
`userForVega.deselectOptions(vegaComboBox, ['label', ...], {keyOrLabel: 'label'}); // will deselect the options according to label`  
  
[**选择选项**: 模拟用户从选中选项](https://testing-library.com/docs/user-event/utility#-selectoptions-deselectoptions)  
用法示例:  
`V14`  
`await userForVega.selectOptions(vegaComboBox, 'label', {keyOrLabel: 'label'}); // will select the option according to label`  
`await userForVega.selectOptions(vegaComboBox, 'key', {keyOrLabel: 'key'}); // will select the option according to key`  
`await userForVega.selectOptions(vegaComboBox, ['label', ...], {keyOrLabel: 'label'}); // will select the options according to label`  
`await userForVega.selectOptions(vegaComboBox, ['key', ...], {keyOrLabel: 'key'}); // will select the options according to key`  
`V13`  
`userForVega.selectOptions(vegaComboBox, 'label', {keyOrLabel: 'label'}); // will select the option according to label`  
`userForVega.selectOptions(vegaComboBox, 'key', {keyOrLabel: 'key'}); // will select the option according to key`  
`userForVega.selectOptions(vegaComboBox, ['label', ...], {keyOrLabel: 'label'}); // will select the options according to label`  
`userForVega.selectOptions(vegaComboBox, ['key', ...], {keyOrLabel: 'key'}); // will select the options according to key`  
  
[**类型**:模拟用户将文本输入组合框](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await userForVega.type(vegaComboBox, 'Peaches'); // will type 'Peaches' in the input box`  
`V13`  
`userForVega.type(vegaComboBox, 'Peaches'); // will type 'Peaches' in the input box`  
 |
| **选择日期者** | [**清除**:模拟用户清除取日期器的值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaDatePicker); //For both single & range mode`  
`V13`  
`userForVega.clear(vegaDatePicker); //For both single & range mode`  
  
[**单击**: 模拟用户点击取日期器](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaDatePicker); //Click start input`  
`await userForVega.click(vegaDatePicker, {startOrEnd: 'start'}); //Click start input`  
`await userForVega.click(vegaDatePicker, {startOrEnd: 'end'}); //Click end input`  
`V13`  
`userForVega.click(vegaDatePicker); //Click start input`  
`userForVega.click(vegaDatePicker, undefined, {startOrEnd: 'start'}); //Click start input`  
`userForVega.click(vegaDatePicker, undefined, {startOrEnd: 'end'}); //Click end input`  
  
[**类型**:模拟用户将文本打入取日期器](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await userForVega.type(vegaDatePicker, '12/12/2000'); //Type in start input`  
`await userForVega.type(vegaDatePicker, '12/12/2000', {startOrEnd: 'start', delay: 0}); //Type in start input`  
`await userForVega.type(vegaDatePicker, '12/12/2000', {startOrEnd: 'end', delay: 0}); //Type in start input`  
`V13`  
`userForVega.type(vegaDatePicker, '12/12/2000'); //Type in start input`  
`userForVega.type(vegaDatePicker, '12/12/2000', {startOrEnd: 'start', delay: 0}); //Type in start input`  
`userForVega.type(vegaDatePicker, '12/12/2000', {startOrEnd: 'end', delay: 0}); //Type in start input`  
 |
| **维加下拉** | [**清除**:模拟用户清除下拉值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaDropdown, 'string'); // Will open dropdown and clear search input`  
`V13`  
`userForVega.clear(vegaDropdown, 'string'); // Will open dropdown and clear search input`  
  
[**单击**: 模拟用户点击下拉](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaDropdown); // will click to open`  
`await userForVega.click(vegaDropdown, { keyOrLabel: 'key', value: 'key' }); // will click dropdown item by item key`  
`await userForVega.click(vegaDropdown, { keyOrLabel: 'key', value: ['key1', 'key2', 'key3'] }); // will click multiple dropdown items by item key`  
`await userForVega.click(vegaDropdown, { keyOrLabel: 'label', value: 'Label 1' }); // will click dropdown item by item label`  
`await userForVega.click(vegaDropdown, { keyOrLabel: 'label', value: ['Label 1', 'Label 2', 'Label 3'] }); // will click multiple dropdown items by item label`  
`await userForVega.click(vegaDropdown, { action: 'reset' }); // will click reset selection button when items are selected`  
`await userForVega.click(vegaDropdown, { action: 'add' }); // will click add item button when searched item is not found`  
`V13`  
`userForVega.click(vegaDropdown); // will click to open`  
`userForVega.click(vegaDropdown, undefined, { keyOrLabel: 'key', value: 'key' }); // will click dropdown item by item key`  
`userForVega.click(vegaDropdown, undefined, { keyOrLabel: 'key', value: ['key1', 'key2', 'key3'] }); // will click multiple dropdown items by item key`  
`userForVega.click(vegaDropdown, undefined, { keyOrLabel: 'label', value: 'Label 1' }); // will click dropdown item by item label`  
`userForVega.click(vegaDropdown, undefined, { keyOrLabel: 'label', value: ['Label 1', 'Label 2', 'Label 3'] }); // will click multiple dropdown items by item label`  
`userForVega.click(vegaDropdown, undefined, { action: 'reset' }); // will click reset selection button when items are selected`  
`userForVega.click(vegaDropdown, undefined, { action: 'add' }); // will click add item button when searched item is not found`  
  
[**类型**: 模拟用户将文本输入下拉](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await userForVega.type(vegaDropdown, 'string'); // Will open dropdown and search by string`  
`V13`  
`userForVega.type(vegaDropdown, 'string'); // Will open dropdown and search by string`  
 |
| **vega- 下拉组** | [**单击**: 模拟用户点击下拉组](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaDropdownGroup); // will click dropdown group first item`  
`await userForVega.click(vegaDropdownGroup, { keyOrLabel: 'key', value: 'item1' }); // will click dropdown item by key`  
`await userForVega.click(vegaDropdownGroup, { keyOrLabel: 'label', value: 'Item 1' }); // will click dropdown item by label`  
`V13`  
`userForVega.click(vegaDropdownGroup); // will click dropdown group first item`  
`userForVega.click(vegaDropdownGroup, undefined, { keyOrLabel: 'key', value: 'item1' }); // will click dropdown item by key`  
`userForVega.click(vegaDropdownGroup, undefined, { keyOrLabel: 'label', value: 'Item 1' }); // will click dropdown item by label`  
 |
| **viga- 下拉项目** | [**单击**: 模拟用户点击下拉项目](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaDropdownItem); // will click dropdown item`  
`V13`  
`userForVega.click(vegaDropdownItem); // will click dropdown item`  
  
[**盘旋**: 模拟用户在下拉项目上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaDropdownItem); // will hover dropdown item`  
`V13`  
`userForVega.hover(vegaDropdownItem); // will hover dropdown item`  
  
[**卸载**: 模拟用户将指针移出下拉项目](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaDropdownItem); // will unhover dropdown item`  
`V13`  
`userForVega.unhover(vegaDropdownItem); // will unhover dropdown item`  
 |
| **vega 文件装入器** | [**清除**: 模拟用户清除文件上传器的值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaFileUploader, {values: 'file name', indexOrName: 'name'}); // Delete file by name`  
`await userForVega.clear(vegaFileUploader, {values: ['file name1', 'file name2', ...], indexOrName: 'name'}); // Delete files by name`  
`await userForVega.clear(vegaFileUploader, {values: '0', indexOrName: 'index'}); // Delete file by index`  
`await userForVega.clear(vegaFileUploader, {values: ['0', '1', ...], indexOrName: 'index'}); // Delete files by index`  
`V13`  
`userForVega.clear(vegaFileUploader, {values: 'file name', indexOrName: 'name'}); // Delete file by name`  
`userForVega.clear(vegaFileUploader, {values: ['file name1', 'file name2', ...], indexOrName: 'name'}); // Delete files by name`  
`userForVega.clear(vegaFileUploader, {values: '0', indexOrName: 'index'}); // Delete file by index`  
`userForVega.clear(vegaFileUploader, {values: ['0', '1', ...], indexOrName: 'index'}); // Delete files by index`  
  
[**上传**: 模拟用户上传文件到文件上传器](https://testing-library.com/docs/user-event/utility#upload)  
用法示例:  
`V14`  
`await userForVega.upload(vegaFileUploader, 'file name'); // will upload the single file according to file name`  
`await userForVega.upload(vegaFileUploader, '['file name', 'file name 1', ....]); // will upload the multiple files according to file names`  
`V13`  
`userForVega.upload(vegaFileUploader, 'file name'); // will upload the single file according to file name`  
`userForVega.upload(vegaFileUploader, '['file name', 'file name 1', ....]); // will upload the multiple files according to file names`  
 |
| **虚拟图像上载器** | [**清除**: 模拟用户清除图像上传器的值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaImageUploader); //Delete uploaded image`  
`V13`  
`userForVega.clear(vegaImageUploader); //Delete uploaded image`  
  
[**单击**: 模拟用户点击图像上传器](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaImageUploader, { action: 'replace', file: file }); //Replace image`  
`await userForVega.click(vegaImageUploader, { action: 'delete' }); //Remove uploaded image`  
`await userForVega.click(vegaImageUploader, { action: 'cancel' }); //Cancel upload of image`  
`await userForVega.click(vegaImageUploader, { action: 'preview' }); //Preview uploaded image`  
`V13`  
`userForVega.click(vegaImageUploader, undefined, { action: 'replace', file: file }); //Replace image`  
`userForVega.click(vegaImageUploader, undefined, { action: 'delete' }); //Remove uploaded image`  
`userForVega.click(vegaImageUploader, undefined, { action: 'cancel' }); //Cancel upload of image`  
`userForVega.click(vegaImageUploader, undefined, { action: 'preview' }); //Preview uploaded image`  
  
[**上传**: 模拟用户上传文件到图像上传器](https://testing-library.com/docs/user-event/utility#upload)  
用法示例:  
`V14`  
`await userForVega.upload(vegaImageUploader, imageFile); //Upload image`  
`V13`  
`userForVega.upload(vegaImageUploader, imageFile); //Upload image`  
 |
| **虚拟输入** | [**清除**: 模拟用户清除输入值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaInput, { iconClear: true }); // Clear input field by clicking the clear icon`  
`await userForVega.clear(vegaInput); // Clear input field by userEvent.clear`  
`V13`  
`userForVega.clear(vegaInput, { iconClear: true }); // Clear input field by clicking the clear icon`  
`userForVega.clear(vegaInput); // Clear input field by userEvent.clear`  
  
[**单击**: 模拟用户点击输入](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaInput); // will click the input box`  
`V13`  
`userForVega.click(vegaInput); // will click the input box`  
  
[**类型**:模拟用户输入文本](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await userForVega.type(vegaInput, 'Hello World'); // will type 'Hello World' in the input box`  
`V13`  
`userForVega.type(vegaInput, 'Hello World'); // will type 'Hello World' in the input box`  
 |
| **虚拟输入-信用卡** | [**清除**:模拟用户清除信用卡输入值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaInputCreditCard); // Clear input field by userEvent.clear`  
`V13`  
`userForVega.clear(vegaInputCreditCard); // Clear input field by userEvent.clear`  
  
[**单击**:模拟用户点击信用卡输入](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaInputCreditCard); // Click input field by userEvent.click`  
`V13`  
`userForVega.click(vegaInputCreditCard); // Click input field by userEvent.click`  
  
[**类型**:模拟用户将文本输入信用卡输入](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await userForVega.type(vegaInputCreditCard, '1234'); // Type into input field by userEvent.type`  
`V13`  
`userForVega.type(vegaInputCreditCard, '1234'); // Type into input field by userEvent.type`  
 |
| **虚拟输入-数字** | [**清除**: 模拟用户清除数字输入值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaInputNumeric, { iconClear: true }); // Clear input field by clicking the clear icon`  
`await userForVega.clear(vegaInputNumeric); // Clear input field by userEvent.clear`  
`V13`  
`userForVega.clear(vegaInputNumeric, { iconClear: true }); // Clear input field by clicking the clear icon`  
`userForVega.clear(vegaInputNumeric); // Clear input field by userEvent.clear`  
  
[**单击**: 模拟用户点击数字输入](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaInputNumeric); // will click the input box`  
`V13`  
`userForVega.click(vegaInputNumeric); // will click the input box`  
  
[**类型**: 模拟用户将文本输入数字输入](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await userForVega.type(vegaInputNumeric, '12345'); // will type '12345' in the input box`  
`V13`  
`userForVega.type(vegaInputNumeric, '12345'); // will type '12345' in the input box`  
 |
| **维加-输入-电话号码** | [**清除**:模拟用户清除电话号码输入值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaInputPhoneNumber); // Clear input field with userEvent clear method`  
`await userForVega.clear(vegaInputPhoneNumber, { source: 'input' }); // Clear input field with userEvent clear method`  
`await userForVega.clear(vegaInputPhoneNumber, { source: 'dropDown' }); // Clear drop down input field with userEvent clear method`  
`await userForVega.clear(vegaInputPhoneNumber, { iconClear: true }); // Clear input field with clear icon button`  
`await userForVega.clear(vegaInputPhoneNumber, { source: 'dropDown', iconClear: true }); // Clear drop down input field with clear icon button`  
`V13`  
`userForVega.clear(vegaInputPhoneNumber); // Clear input field with userEvent clear method`  
`userForVega.clear(vegaInputPhoneNumber, { source: 'input' }); // Clear input field with userEvent clear method`  
`userForVega.clear(vegaInputPhoneNumber, { source: 'dropDown' }); // Clear drop down input field with userEvent clear method`  
`userForVega.clear(vegaInputPhoneNumber, { iconClear: true }); // Clear input field with clear icon button`  
`userForVega.clear(vegaInputPhoneNumber, { source: 'dropDown', iconClear: true }); // Clear drop down input field with clear icon button`  
  
[**选择选项**: 模拟用户从选中选项](https://testing-library.com/docs/user-event/utility#-selectoptions-deselectoptions)  
用法示例:  
`V14`  
`await userForVega.selectOptions(vegaInputPhoneNumber, 'key', {keyOrLabel: 'key'}); // Select option by key using userEvent.click`  
`await userForVega.selectOptions(vegaInputPhoneNumber, 'label', {keyOrLabel: 'label'}); // Select option by label using userEvent.click`  
`V13`  
`userForVega.selectOptions(vegaInputPhoneNumber, 'key', {keyOrLabel: 'key'}); // Select option by key using userEvent.click`  
`userForVega.selectOptions(vegaInputPhoneNumber, 'label', {keyOrLabel: 'label'}); // Select option by label using userEvent.click`  
  
[**类型**: 模拟用户将文本输入电话号码输入](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await userForVega.type(vegaInputPhoneNumber, '123', {source: 'input'}); // Type into input field or dropdown input field using userEvent.type`  
`V13`  
`userForVega.type(vegaInputPhoneNumber, '123', {source: 'input', delay: 0}); // Type into input field or dropdown input field using userEvent.type`  
 |
| **输入范围** | [**清除**: 模拟用户清除范围输入值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaInputRange); // Clear minimum input field using userEvent.clear (keyboard action)`  
`await userForVega.clear(vegaInputRange, {minOrMax: 'min'}); // Clear minimum input field using userEvent.clear (keyboard action)`  
`await userForVega.clear(vegaInputRange, {minOrMax: 'max'}); // Clear maximum input field using userEvent.clear (keyboard action)`  
`await userForVega.clear(vegaInputRange, {iconClear: true}); // Clear both fields (min and max) using the clear icon`  
`V13`  
`userForVega.clear(vegaInputRange); // Clear minimum input field using userEvent.clear (keyboard action)`  
`userForVega.clear(vegaInputRange, {minOrMax: 'min'}); // Clear minimum input field using userEvent.clear (keyboard action)`  
`userForVega.clear(vegaInputRange, {minOrMax: 'max'}); // Clear maximum input field using userEvent.clear (keyboard action)`  
`userForVega.clear(vegaInputRange, {iconClear: true}); // Clear both fields (min and max) using the clear icon`  
  
[**单击**: 模拟点击范围输入的用户](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaInputRange, {minOrMax: 'min'}); // will click the minimum input box`  
`await userForVega.click(vegaInputRange, {minOrMax: 'max'}); // will click the maximum input box`  
`V13`  
`userForVega.click(vegaInputRange, undefined, {minOrMax: 'max'}); // will click the maximum input box`  
  
[**类型**: 模拟用户将文本输入范围输入](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await userForVega.type(vegaInputRange, '10', {minOrMax: 'min'}); // will type '10' in the minimum input box`  
`await userForVega.type(vegaInputRange, '10', {minOrMax: 'max'}); // will type '10' in the maximum input box`  
`V13`  
`userForVega.type(vegaInputRange, '10', {minOrMax: 'min', delay: 0}); // will type '10' in the minimum input box`  
`userForVega.type(vegaInputRange, '10', {minOrMax: 'max', delay: 0}); // will type '10' in the maximum input box`  
 |
| **虚拟输入选择** | [**取消选择选项**: 模拟用户从多选项中取消选择选项](https://testing-library.com/docs/user-event/utility#-selectoptions-deselectoptions)  
用法示例:  
`V14`  
`await userForVega.deselectOptions(vegaInputSelect, ['key', 'key1', ...], {keyOrLabel: 'key'}); // will deselect the option with specified key`  
`await userForVega.deselectOptions(vegaInputSelect, ['label', 'label1', ...], {keyOrLabel: 'label'}); // will deselect the option with specified label`  
`V13`  
`userForVega.deselectOptions(vegaInputSelect, ['key', 'key1', ...], {keyOrLabel: 'key'}); // will deselect the option with specified key`  
`userForVega.deselectOptions(vegaInputSelect, ['label', 'label1', ...], {keyOrLabel: 'label'}); // will deselect the option with specified label`  
  
[**选择选项**: 模拟用户从选中选项](https://testing-library.com/docs/user-event/utility#-selectoptions-deselectoptions)  
用法示例:  
`V14`  
`await userForVega.selectOptions(vegaInputSelect, 'key', {keyOrLabel: 'key'}); // will select the option with specified key`  
`await userForVega.selectOptions(vegaInputSelect, ['label', 'label1', ...], {keyOrLabel: 'label'}); // will select the option with specified label`  
`V13`  
`userForVega.selectOptions(vegaInputSelect, 'label', {keyOrLabel: 'label'}); // will select the option with specified label`  
`userForVega.selectOptions(vegaInputSelect, ['key', 'key1', ...], {keyOrLabel: 'key'}); // will select the options with specified keys`  
  
[**类型**:模拟用户将文本输入到选定的输入中](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await userForVega.type(vegaInputSelect, 'Peaches'); // will type 'text' in the input box and filter options by label`  
`V13`  
`userForVega.type(vegaInputSelect, 'Peaches'); // will type 'text' in the input box and filter options by label`  
 |
| **viga- 对象切换** | [**单击**: 模拟用户点击项目切换](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaItemToggle); // will click item toggle`  
`await waitFor(() => { expect(vegaItemToggle.isToggled).toBe(true); }, { timeout: 1550 }); // wait for the toggle animation to finish`  
`V13`  
`userForVega.click(vegaItemToggle); // will click item toggle`  
`await waitFor(() => { expect(vegaItemToggle.isToggled).toBe(true); }, { timeout: 1550 }); // wait for the toggle animation to finish`  
 |
| **vega- 左向导航组** | [**单击**: 模拟用户点击左侧导航组](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaLeftNavGroup); //Click left nav group`  
`V13`  
`userForVega.click(vegaLeftNavGroup); //Click left nav group`  
  
[**盘旋**:模拟一个在左侧导航组上徘徊指针的用户](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaLeftNavGroup); //hover left nav group`  
`V13`  
`userForVega.hover(vegaLeftNavGroup); //hover left nav group`  
  
[**卸载**:模拟用户将指针从左侧导航组移出](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaLeftNavGroup); //unhover left nav group`  
`V13`  
`userForVega.unhover(vegaLeftNavGroup); //unhover left nav group`  
 |
| **vega-左向导航链接** | [**单击**: 模拟用户点击左侧导航链接](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaLeftNavLink); //Click left nav link`  
`V13`  
`userForVega.click(vegaLeftNavLink); //Click left nav link`  
  
[**盘旋**:模拟用户在左向导航链接上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaLeftNavLink); //hover left nav link`  
`V13`  
`userForVega.hover(vegaLeftNavLink); //hover left nav link`  
  
[**卸载**:模拟用户将指针移出左向导航链接](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaLeftNavLink); //unhover left nav link`  
`V13`  
`userForVega.unhover(vegaLeftNavLink); //unhover left nav link`  
 |
| **vega-左向导航区** | [**单击**:模拟用户点击左侧导航部分](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaLeftNavSection); //Click left nav section action button link if action title is set`  
`V13`  
`userForVega.click(vegaLeftNavSection); //Click left nav section action button link if action title is set`  
  
[**盘旋**: 模拟一个用户在左侧导航段盘旋指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaLeftNavSection); //hover left nav section action button link if action title is set`  
`V13`  
`userForVega.hover(vegaLeftNavSection); //hover left nav section action button link if action title is set`  
  
[**卸载**: 模拟一个用户将指针移出左侧导航部分](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaLeftNavSection); //unhover left nav section`  
`V13`  
`userForVega.unhover(vegaLeftNavSection); //unhover left nav section`  
 |
| **虚拟模式** | [**单击**: 模拟用户点击模式](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaModal); // will simulate click to open modal`  
`await userForVega.click(vegaModal, { action: 'open' }); // will open modal`  
`await userForVega.click(vegaModal, { action: 'close' }); // will close modal`  
`await userForVega.click(vegaModal, { target: 'closeIcon' }); // On open modal, click close icon`  
`V13`  
`userForVega.click(vegaModal); // will simulate click to open modal`  
`userForVega.click(vegaModal, undefined, { action: 'open' }); // will open modal`  
`userForVega.click(vegaModal, undefined, { action: 'close' }); // will close modal`  
`userForVega.click(vegaModal, { target: 'closeIcon' }); // On open modal, click close icon`  
 |
| **虚拟导航卡** | [**单击**: 模拟点击导航卡的用户](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaNavCard); //Click first vega-left-nav-link by default`  
`await userForVega.click(vegaNavCard, { prop: 'key', propValue: 'settings' }); //Click nav item by key:'settings'`  
`await userForVega.click(vegaNavCard, { prop: 'url', propValue: '#settings' }); //Click nav item by url`  
`await userForVega.click(vegaNavCard, { prop: 'label', propValue: 'SETTINGS' }); //Click nav item by label text`  
`await userForVega.click(vegaNavCard, { prop: 'label', propValue: 'Profile', targetType: 'group' }); //Click label for for group element`  
`V13`  
`userForVega.click(vegaNavCard); //Click first vega-left-nav-link by default`  
`userForVega.click(vegaNavCard, undefined, { prop: 'key', propValue: 'settings' }); //Click nav item by key:'settings'`  
`userForVega.click(vegaNavCard, undefined, { prop: 'url', propValue: '#settings' }); //Click nav item by url`  
`userForVega.click(vegaNavCard, undefined, { prop: 'label', propValue: 'SETTINGS' }); //Click nav item by label text`  
`userForVega.click(vegaNavCard, undefined, { prop: 'label', propValue: 'Profile', targetType: 'group' }); //Click label for for group element`  
 |
| **vega- 涂鸦** | [**单击**: 模拟用户点击页码](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaPagination, { next: true }); // go to next page`  
`await userForVega.click(vegaPagination, { prev: true }); // go to previous page`  
`await userForVega.click(vegaPagination, { page: 5 }); // go to specific page`  
`V13`  
`userForVega.click(vegaPagination, undefined, { next: true }); // go to next page`  
`userForVega.click(vegaPagination, undefined, { prev: true }); // go to previous page`  
`userForVega.click(vegaPagination, undefined, { page: 5 }); // go to specific page`  
  
[**选择选项**: 模拟用户从选中选项](https://testing-library.com/docs/user-event/utility#-selectoptions-deselectoptions)  
用法示例:  
`V14`  
`await waitFor(() => { expect(vegaPagination.shadowRoot.querySelector('vega-input-select').classList.contains('hydrated')).toBe(true); }); // wait for the inner input-select to be rendered.`  
`await userForVega.selectOptions(vegaPagination, '20'); // change page size to 20`  
`V13`  
`await waitFor(() => { expect(vegaPagination.shadowRoot.querySelector('vega-input-select').classList.contains('hydrated')).toBe(true); }); // wait for the inner input-select to be rendered.`  
`userForVega.selectOptions(vegaPagination, '20'); // change page size to 20`  
  
[**类型**:模拟用户将文本输入到页码](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await waitFor(() => { expect(vegaPagination.shadowRoot.querySelector('vega-input[data-vega-form="paginationGoTo"]').classList.contains('hydrated')).toBe(true); }); // wait for the inner vega-input to be rendered.`  
`await userForVega.type(vegaPagination, '5'); // type target page number and goTo that page`  
`V13`  
`await waitFor(() => { expect(vegaPagination.shadowRoot.querySelector('vega-input[data-vega-form="paginationGoTo"]').classList.contains('hydrated')).toBe(true); }); // wait for the inner vega-input to be rendered.`  
`userForVega.type(vegaPagination, '5'); // type target page number and goTo that page`  
 |
| **维加 - 流行** | [**单击**: 模拟用户点击弹出器](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaPopover); // will click popover-content slot to open or close the popover`  
`V13`  
`userForVega.click(vegaPopover); // will click popover-content slot to open or close the popover`  
  
[**盘旋**:模拟用户在弹出器上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaPopover); // will hover popover-content slot to open or close the popover`  
`V13`  
`userForVega.hover(vegaPopover); // will hover popover-content slot to open or close the popover`  
  
[**卸载**:模拟用户将指针移出弹出器](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaPopover); // will unhover popover-content slot to open or close the popover`  
`await waitFor(() => { expect(vegaPopoverContent).toHaveClass('vega-force-hidden');}); // wait for the popover to be hidden`  
`V13`  
`userForVega.unhover(vegaPopover); // will unhover popover-content slot to open or close the popover`  
`await waitFor(() => { expect(vegaPopoverContent).toHaveClass('vega-force-hidden');}); // wait for the popover to be hidden`  
 |
| **维加无线电** | [**单击**: 模拟用户点击收音机](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaRadio); // will click radio`  
`V13`  
`userForVega.click(vegaRadio); // will click radio`  
  
[**盘旋**:模拟一个用户在收音机上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaRadio); // will hover radio`  
`V13`  
`userForVega.hover(vegaRadio); // will hover radio`  
  
[**卸载**:模拟一个用户将指针移出收音机](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaRadio); // will unhover radio`  
`V13`  
`userForVega.unhover(vegaRadio); // will unhover radio`  
 |
| **区域控制** | [**单击**: 模拟用户点击段控件](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaSegmentControl, {value: 'Right', textOrIndexOrKey: 'text'}); // will click the right button`  
`await userForVega.click(vegaSegmentControl, {value: 'Center', textOrIndexOrKey: 'text'}); // will click the center button`  
`await userForVega.click(vegaSegmentControl, {value: 'left', textOrIndexOrKey: 'text'}); // will click the left button`  
`await userForVega.click(vegaSegmentControl, {value: '1', textOrIndexOrKey: 'index'}); // will click the first button by index`  
`await userForVega.click(vegaSegmentControl, {value: 'right', textOrIndexOrKey: 'key'}); // will click the button with key 'right'`  
`await userForVega.click(vegaSegmentControl, {value: 'center', textOrIndexOrKey: 'key'}); // will click the button with key 'center'`  
`await userForVega.click(vegaSegmentControl, {value: 'left', textOrIndexOrKey: 'key'}); // will click the button with key 'left'`  
`V13`  
`userForVega.click(vegaSegmentControl, undefined, {value: 'Right', textOrIndexOrKey: 'text'}); // will click the right button`  
`userForVega.click(vegaSegmentControl, undefined, {value: 'Center', textOrIndexOrKey: 'text'}); // will click the center button`  
`userForVega.click(vegaSegmentControl, undefined, {value: 'left', textOrIndexOrKey: 'text'}); // will click the left button`  
`userForVega.click(vegaSegmentControl, undefined, {value: '1', textOrIndexOrKey: 'index'}); // will click the first button by index`  
`userForVega.click(vegaSegmentControl, undefined, {value: 'right', textOrIndexOrKey: 'key'}); // will click the button with key 'right'`  
`userForVega.click(vegaSegmentControl, undefined, {value: 'center', textOrIndexOrKey: 'key'}); // will click the button with key 'center'`  
`userForVega.click(vegaSegmentControl, undefined, {value: 'left', textOrIndexOrKey: 'key'}); // will click the button with key 'left'`  
 |
| **维加- 选择- 芯片** | [**清除**: 模拟用户清除选择芯片的值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaSelectionChip); //clear selection chip`  
`V13`  
`userForVega.clear(vegaSelectionChip); //clear selection chip`  
  
[**单击**: 模拟用户点击选择芯片](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaSelectionChip); //click selection chip`  
`V13`  
`userForVega.click(vegaSelectionChip); //click selection chip`  
  
[**盘旋**:模拟用户在选择芯片上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaSelectionChip); //hover on selection chip`  
`V13`  
`userForVega.hover(vegaSelectionChip); //hover on selection chip`  
  
[**卸载**:模拟用户将指针移出选择芯片](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaSelectionChip); //unhover selection chip`  
`V13`  
`userForVega.unhover(vegaSelectionChip); //unhover selection chip`  
 |
| **vega - 选择- 芯片组** | [**清除**: 模拟用户清除选择芯片组的值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaSelectionChipGroup); //clear group selection`  
`V13`  
`userForVega.clear(vegaSelectionChipGroup); //clear group selection`  
  
[**单击**: 模拟用户点击选择芯片组](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaSelectionChipGroup, {label: 'Label for ABC'}); //Select by label`  
`await userForVega.click(vegaSelectionChipGroup, {label: ['Label for ABC', 'Label for DEF']}); //Multi select`  
`await userForVega.click(vegaSelectionChipGroup, {value: 'ABC'}); //Select by value`  
`await userForVega.click(vegaSelectionChipGroup, {value: ['ABC', 'DEF']}); //Multi select`  
`V13`  
`userForVega.click(vegaSelectionChipGroup, undefined, {label: 'Label for ABC'}); //Select by label`  
`userForVega.click(vegaSelectionChipGroup, undefined, {label: ['Label for ABC', 'Label for DEF']}); //Multi select`  
`userForVega.click(vegaSelectionChipGroup, undefined, {value: 'ABC'}); //Select by value`  
`userForVega.click(vegaSelectionChipGroup, undefined, {value: ['ABC', 'DEF']}); //Multi select`  
 |
| **vega - 选择牌** | [**清除**: 模拟一个用户清除选择牌的值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaSelectionTile); //Clear selection`  
`V13`  
`userForVega.clear(vegaSelectionTile); //Clear selection`  
  
[**单击**: 模拟用户点击所选牌](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaSelectionTile); //Click selection tile`  
`V13`  
`userForVega.click(vegaSelectionTile); //Click selection tile`  
  
[**盘旋**:模拟用户在选择的平板上徘徊指针](https://testing-library.com/docs/user-event/convenience#hover)  
用法示例:  
`V14`  
`await userForVega.hover(vegaSelectionTile); //Hover on selection tile`  
`V13`  
`userForVega.hover(vegaSelectionTile); //Hover on selection tile`  
  
[**卸载**:模拟一个用户将指针移出选择牌](https://testing-library.com/docs/user-event/convenience#unhover)  
用法示例:  
`V14`  
`await userForVega.unhover(vegaSelectionTile); //Unhover on selection tile`  
`V13`  
`userForVega.unhover(vegaSelectionTile); //Unhover on selection tile`  
 |
| **vega - 选择牌组** | [**清除**: 模拟用户清除选中的平板组的值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaSelectionTileGroup); // Clear selected values`  
`V13`  
`userForVega.clear(vegaSelectionTileGroup); // Clear selected values`  
  
[**单击**: 模拟用户点击所选的平板组](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaSelectionTileGroup, {value: 'ABC'}); //Select by value`  
`await userForVega.click(vegaSelectionTileGroup, {value: ['ABC', 'DEF']}); //Select multiple options`  
`await userForVega.click(vegaSelectionTileGroup, {title: 'Title for ABC'}); //Select by title`  
`await userForVega.click(vegaSelectionTileGroup, {title: ['Title ABC', 'Title DEF']}); //Select multiple options`  
`V13`  
`userForVega.click(vegaSelectionTileGroup, undefined, {value: 'ABC'}); //Select by value`  
`userForVega.click(vegaSelectionTileGroup, undefined, {value: ['ABC', 'DEF']}); //Select multiple options`  
`userForVega.click(vegaSelectionTileGroup, undefined, {title: 'Title for ABC'}); //Select by title`  
`userForVega.click(vegaSelectionTileGroup, undefined, {title: ['Title ABC', 'Title DEF']}); //Select multiple options`  
 |
| **维加签名-抓取** | [**清除**: 模拟用户清除签名抓取值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaSignatureCapture); // Clear the signature capture`  
`V13`  
`userForVega.clear(vegaSignatureCapture); // Clear the signature capture`  
  
[**指针**: 模拟指向签名抓取的用户](https://testing-library.com/docs/user-event/pointer)  
用法示例:  
`V14`  
`await userForVega.pointer(vegaSignatureCapture, [{ keys: '[MouseLeft>]', coords: { x: 100, y: 200 } },{ coords: { x: 200, y: 200 } },{ keys: '[/MouseLeft]' },]); // Draw a signature`  
`V13`  
`userForVega.pointer(vegaSignatureCapture, [{mouseDown: { clientX: 100, clientY: 200 }, mouseMove: { clientX: 200, clientY: 200 }, mouseUp: { clientX: 200, clientY: 200 },},]); // Draw a signature`  
 |
| **vega 步进器** | [**清除**: 模拟用户清除阶梯值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaStepper); // will clear the stepper input and set the value to 0`  
`V13`  
`userForVega.clear(vegaStepper); // will clear the stepper input and set the value to 0`  
  
[**单击**: 模拟用户点击阶梯](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaStepper, {actionSource: 'minus'}); // Decrease value`  
`await userForVega.click(vegaStepper, {actionSource: 'plus'}); // Increase value`  
`await userForVega.click(vegaStepper, {actionSource: 'input'}); // To focus on the input`  
`V13`  
`userForVega.click(vegaStepper, undefined, {actionSource: 'minus'}); // Decrease value`  
`userForVega.click(vegaStepper, undefined, {actionSource: 'plus'}); // Increase value`  
`userForVega.click(vegaStepper, undefined, {actionSource: 'input'}); // To focus on the input`  
  
[**类型**:模拟用户将文本输入到阶梯](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await userForVega.type(vegaStepper, '10'); // will type '10' in the stepper input`  
`V13`  
`userForVega.type(vegaStepper, '10'); // will type '10' in the stepper input`  
 |
| **虚拟文本区域** | [**清除**: 模拟用户清除文本区域的值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaTextarea); // Delete all text`  
`V13`  
`userForVega.clear(vegaTextarea); // Delete all text`  
  
[**单击**: 模拟用户点击文本区域](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaTextarea); // click textarea`  
`V13`  
`userForVega.click(vegaTextarea); // click textarea`  
  
[**类型**:模拟用户将文本输入文本区域](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await userForVega.type(vegaTextarea, 'text'); // will type 'text' in the textarea box`  
`V13`  
`userForVega.type(vegaTextarea, 'text'); // will type '12345' in the textarea box`  
 |
| **时间选择者** | [**清除**: 模拟用户清除取时器的值](https://testing-library.com/docs/user-event/utility#clear)  
用法示例:  
`V14`  
`await userForVega.clear(vegaTimePicker); // Clear start time input`  
`await userForVega.clear(vegaTimePicker, {startOrEnd: 'start'}); // Clear start time input`  
`await userForVega.clear(vegaTimePicker, {startOrEnd: 'end'}); // Clear end time input`  
`V13`  
`userForVega.clear(vegaTimePicker); // Clear start time input`  
`userForVega.clear(vegaTimePicker, {startOrEnd: 'start'}); // Clear start time input`  
`userForVega.clear(vegaTimePicker, {startOrEnd: 'end'}); // Clear end time input`  
  
[**单击**: 模拟点击取时器的用户](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaTimePicker); // Click start time input field`  
`await userForVega.click(vegaTimePicker, {startOrEnd: 'start'}); // Click start time input field`  
`await userForVega.click(vegaTimePicker, {startOrEnd: 'end'}); // Click end time input field`  
`V13`  
`userForVega.click(vegaTimePicker, undefined, {startOrEnd: 'start'}); // Click start time input field`  
`userForVega.click(vegaTimePicker, undefined, {startOrEnd: 'end'}); // Click end time input field`  
  
[**类型**:模拟用户将文本输入取时器](https://testing-library.com/docs/user-event/utility#type)  
用法示例:  
`V14`  
`await userForVega.type(vegaTimePicker, '10:00'); // Type into start time input field`  
`await userForVega.type(vegaTimePicker, '10:00', {startOrEnd: 'start'}); // Type into start time input field`  
`await userForVega.type(vegaTimePicker, '11:15', {startOrEnd: 'end'}); // Type into end time input field`  
`V13`  
`userForVega.type(vegaTimePicker, '10:00', {startOrEnd: 'start', delay: 0}); // Type into start time input field`  
`userForVega.type(vegaTimePicker, '10:00', {startOrEnd: 'end', delay: 0}); // Type into end time input field`  
 |
| **虚拟切换** | [**单击**: 模拟用户点击切换开关](https://testing-library.com/docs/user-event/convenience#click)  
用法示例:  
`V14`  
`await userForVega.click(vegaToggleSwitch); // will click toggle switch`  
`V13`  
`userForVega.click(vegaToggleSwitch); // will click toggle switch`  
 |

## 常见问题

### @globalpayments/vega-testing-library 是什么？

一个轻量级测试工具,可以扩展出@testing-library/user-event,以无缝模拟用户与Vega Web组件的互动\.

### 如何安装 @globalpayments/vega-testing-library？

在项目目录运行 npm install @globalpayments/vega-testing-library，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@globalpayments/vega（\*）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @globalpayments/vega-testing-library 支持 TypeScript 吗？

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

### @globalpayments/vega-testing-library 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @globalpayments/vega-testing-library 可以商用吗？

@globalpayments/vega-testing-library 使用 UNLICENSED 许可。作者声明为 UNLICENSED，即不授予公开使用许可（与公共领域的 Unlicense 不同）。使用前需获得作者授权。以上为概括，不构成法律意见，请以许可原文为准。

### @globalpayments/vega-testing-library 的下载量有多少？

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

### @globalpayments/vega-testing-library 还在维护吗？

最新版本 1\.3\.4 发布于 2026/05/28（5 个月前）；至今共发布 2 个版本，其中过去 12 个月发布了 2 个；首次发布于 2026/05/28。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

