Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计通过

hyva-playwright-testhyva Playwright 测试

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

7,080

周安装

298

GitHub Stars

64

下载量

2,479
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:hyva-playwright-test(hyva Playwright 测试)
来源仓库:https://github.com/hyva-themes/hyva-ai-tools
仓库路径:skills/hyva-playwright-test
安装命令:
npx skills add https://github.com/hyva-themes/hyva-ai-tools --skill hyva-playwright-test
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/hyva-themes/hyva-ai-tools --skill hyva-playwright-test

简介

hyva-playwright-test 辅助测试设计、自动化测试和回归验证,支持端到端测试编写。

  • 适用于单元测试、用例整理和失败日志分析,需确认测试框架和运行命令。
  • 可帮助定位问题但应避免为了通过测试而改坏真实逻辑。
  • 涉及浏览器或外部服务时需区分本地模拟、测试环境和生产环境。
  • 建议结合项目夹具数据和测试规范使用,确保测试有效性。

SKILL.md

Writing Playwright Tests for Hyvä + Alpine.js

Overview

Hyvä replaces Luma's KnockoutJS/RequireJS/jQuery with Alpine.js + Tailwind CSS. Playwright's strict mode (rejects locators matching multiple elements) conflicts with Alpine.js DOM patterns where hidden elements exist throughout the page. This skill documents pitfalls and solutions discovered while writing Playwright tests for Hyvä storefronts.

The #1 Rule: Hidden Alpine Elements

Hyvä templates scatter elements like <div x-show="displayErrorMessage" class="message error"> throughout the DOM. These are invisible but present, so a bare selector like .message.error matches both hidden and visible instances, causing Playwright strict mode violations.

Always scope page-level messages to the #messages container:

// WRONG — matches hidden Alpine x-show elements throughout DOM
await expect(page.locator('.message.success')).toContainText('Added to cart');
await expect(page.locator('.message-error')).toContainText('Error');

// RIGHT — scoped to the visible messages container
await expect(page.locator('#messages .message.success')).toContainText('Added to cart');
await expect(page.locator('#messages .message-error, #messages .message.error')).toContainText('Error');

Never use: bare .message, .message.error, .message.success, or div.message as selectors.

Exception — inline page messages: Not all .message elements are flash messages. The search results "no results" notice (.message.notice) renders as static inline content inside #maincontent, not inside the #messages container. For these inline messages, the bare class selector is correct.

Selector Strategy

Follow Playwright's recommended locator priority:

  1. getByRole() — always prefer — closest to how users perceive the page. Avoids text ambiguity where the same text appears in headings, links, breadcrumbs, and sr-only spans.
  2. getByLabel() — for form controls (checkboxes, inputs with associated labels).
  3. getByText() — for non-interactive elements, scoped to a container (e.g., page.locator('#maincontent').getByText(...)).
  4. getByPlaceholder(), getByAltText() — for inputs and images respectively.
  5. getByTestId() — when Hyvä provides data-testid attributes or when adding custom test IDs.
  6. CSS selectors — last resort, only when user-facing locators aren't available. Prefer aria-* attribute selectors (e.g., [aria-label="pagination"], [aria-current="page"]) over class-based selectors. When CSS is necessary, scope to a unique container (e.g., #messages.message.success).

Avoid: :visible pseudo-selector — per Playwright docs, "it's usually better to find a more reliable way to uniquely identify the element." Scope to a container or use role/attribute selectors instead. Only use :visible as an absolute last resort when the DOM provides no other way to distinguish elements.

Alpine.js Interaction Patterns

PatternProblemSolution
x-show hidden elementsStrict mode: multiple matchesScope to unique container (#messages), use role/attribute selectors
x-defer="intersect"Element not initialized until visiblescrollIntoViewIfNeeded() before interacting
x-if (template)Elements don't exist in DOM until condition trueClick the trigger first, then query children
x-model on inputsAlpine clears value after form submitDon't assert input value post-submit; verify via success message
x-text / x-html asyncCart badge updates asynchronouslyUse web-first assertions with timeout: not.toHaveText('0', {timeout: 15_000})
x-show submenusHidden until hoverhover() on parent before clicking child
Alpine form revealFields hidden until checkbox checkedwaitFor({state: 'visible'}) after checking the checkbox
press('Enter') on inputMay submit Alpine-bound form unexpectedlyPrefer explicit .click() on submit button

Assertions

Always use web-first assertions that auto-wait and retry:

// DO — auto-retries             // DON'T — no retry
await expect(loc).toBeVisible(); // expect(await loc.isVisible()).toBe(true);
await expect(loc).toContainText('X'); // expect(await loc.textContent()).toContain('X');

For async Alpine.js updates (cart counts, prices), use extended timeouts on the assertion — never waitForTimeout():

// Cart count updates asynchronously via Alpine x-text
await expect(page.locator('#menu-cart-icon span[x-text="summaryCount"]'))
  .not.toHaveText('0', { timeout: 15_000 });

Hyvä vs Luma Selector Differences

ElementHyvä SelectorLuma Selector
Pagination navgetByRole('navigation', {name: 'pagination'})ul.pages-items
Page linkgetByRole('link', {name: 'Page 2'}).pages-items li a
Active page[aria-current="page"]<strong> element
Filter buttongetByRole('button', {name: 'Color filter'}).filter-options-title
Cart icon badge#menu-cart-icon > span[x-text="summaryCount"].counter-number
Account menu#customer-menu + nav.customer-menu
Success message#messages.message.success.message-success
Error message#messages.message-error, #messages.message.error.message-error
Main menugetByRole('navigation', {name: 'Main menu'})nav.navigation
Footer navgetByRole('navigation', {name: 'Company Menu'}).getByRole('link', {name})nav ul li:nth-child(N) a
Product image#gallery img[itemprop="image"]#gallery img:visible
Add to Cart (card)getByRole('button', {name: /Add to Cart/}).first()button.btn-primary:visible

References

See references/ for code examples. Load files relevant to the current task:

Always useful:

Page-specific (load when testing that page):

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.41%
按下载量换算952

Claude

30.02%
按下载量换算744

Cursor

19.8%
按下载量换算491

Gemini CLI

9.03%
按下载量换算224

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills