Skip to main content

playwright-dotnet-refactor

Refactor generated Playwright .NET test drafts into readable xUnit tests with role-based locators, intent-based assertions, and minimal helper extraction. Use when a generated Playwright test is noisy, brittle, or hard to maintain and needs cleanup without changing user intent.

Datos de origen

Repositorio
NimblePros/eShopOnWeb
Última actividad en el origen
9 de julio de 2026 a las 22:17
Idioma detectado de SKILL.md
inglés
Estrellas
633
Forks
294

Opciones de instalación

De forma predeterminada está seleccionado el prompt que primero revisa el origen. Puedes cambiar a un comando directo o descargar una copia local.

Revisa los archivos de origen

Lee SKILL.md y los archivos complementarios que muestra SkillsMP antes de decidir si quieres instalarlo.

Explorador de archivos
2 archivos

Mostrando SKILL.md

SKILL.md
Instrucciones de origen · Vista previa de solo lectura
name
playwright-dotnet-refactor
description
Refactor generated Playwright .NET test drafts into readable xUnit tests with role-based locators, intent-based assertions, and minimal helper extraction. Use when a generated Playwright test is noisy, brittle, or hard to maintain and needs cleanup without changing user intent.
metadata
{"author":"nimblepros","version":"1.0","spec":"agentskills.io"}
# Playwright .NET Refactor Skill ## Purpose Turn generated Playwright .NET test code into maintainable xUnit tests while preserving the original user journey and intent. ## Use This Skill When - You have generated Playwright C# code from codegen and want production-quality tests. - Selectors are brittle (CSS-heavy, position-dependent, implementation-coupled). - Assertions are missing, weak, or coupled to internals instead of user-visible outcomes. - Test flow is hard to read and would benefit from light structure. ## Inputs To Gather Before Refactor 1. Raw generated Playwright C# test draft. 2. Intended user scenario in one sentence. 3. Target location for test (file/class name). 4. Existing fixture and conventions in the repo (for this repo, prefer xUnit and BrowserFixture patterns). 5. Any known app constraints (auth state, seed data, environment, flaky selectors). ## Refactor Rules 1. Preserve user intent. - Keep the same user-visible workflow and expected behavior. - Do not silently add or remove meaningful scenario steps. 2. Prefer role-based locators. - Prioritize GetByRole, then GetByLabel/GetByPlaceholder, then GetByText, then GetByTestId. - Avoid brittle CSS/XPath selectors unless no better semantic locator exists. 3. Produce readable xUnit tests. - Use clear test names describing behavior and expected outcome. - Keep Arrange/Act/Assert intent obvious through structure and naming. - Minimize incidental complexity in the main test body. 4. Extract helpers only when readability improves. - Extract repeated or noisy interaction sequences. - Keep helpers small and intention-revealing. - Do not introduce abstractions that hide simple steps. 5. Avoid implementation-detail assertions. - Assert only user-observable behavior (visible text, accessible state, navigation outcome, enabled/disabled controls, etc.). - Do not assert internal IDs, hidden DOM structure, CSS class internals, or framework-specific plumbing unless user-visible behavior depends on them. 6. Keep tests deterministic. - Prefer Playwright assertions and explicit waits tied to user-visible conditions. - Avoid arbitrary sleeps. ## Output Contract Return: 1. Refactored C# xUnit test code. 2. Optional helper/page object code only if it materially improves readability. 3. Short rationale list covering: - Locator improvements made. - Assertion improvements made. - Helper extraction decisions. - Any uncertainty or assumptions. ## Quality Gate Checklist - User intent preserved. - Locators are semantic and stable. - Assertions are user-observable. - Test reads clearly top-to-bottom. - No unnecessary abstraction introduced. - No arbitrary waits or timing hacks. ## Prompt Starter Use [assets/refactor-prompt-template.md](assets/refactor-prompt-template.md) as the reusable Level 2 prompt.
Ver en GitHub